Post

Replies

Boosts

Views

Activity

ImageRenderer on iOS - generates blurry image, .scale ineffective?
I'm getting a low quality image when using ImageRenderer on iOS16 both on simulator and device. i.e. when saving the rendered image to the Photo Library or sending to Notes.. it's very pixelated. Everything I read would suggest simply setting .scale but that appears to have no effect. I'm including a sample project. You can see the commented out sections which also fail. It would seem that scale is being ignored completely. Has anyone else experienced this? struct helloWorldView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundColor(.accentColor) Text("Hello, world!") } } } struct ContentView: View { @State private var screenshotimage: UIImage? @State private var screenshot: Bool = false @State private var showsharesheet: Bool = false @State private var sharescreenshot: Bool = false @State private var imageToShare: Image? var body: some View { NavigationStack { helloWorldView() .padding() .toolbar { ToolbarItem(placement: .primaryAction) { Button("Share") { showsharesheet.toggle() } } } .sheet(isPresented: self.$showsharesheet) { NavigationStack { ScrollView { Section { if screenshotimage != nil { Image(uiImage: screenshotimage!) ShareLink( item: Image(uiImage: screenshotimage!), preview: SharePreview( "Share Title", image: Image(uiImage: screenshotimage!) ) ) { Label("Share Image", systemImage: "square.and.arrow.up") .foregroundColor(.white) .padding() .background(.blue.gradient.shadow(.drop(radius: 1, x: 2, y: 2)), in: RoundedRectangle(cornerRadius: 5)) } } else { Text("Creating image..") } } } .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Dismiss") { showsharesheet = false } } } .navigationTitle("Preview") .navigationBarTitleDisplayMode(.inline) } .onAppear() { screenshot.toggle() } .onChange(of: screenshot, perform: { _ in // Task { let renderer = ImageRenderer(content:helloWorldView()) // renderer.scale = UIScreen.main.scale renderer.scale = 3.0 screenshotimage = renderer.uiImage // } }) } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
4
3
3.7k
Dec ’22
Guided Capture sample - broken with iOS17 beta 4
Sample project from: https://developer.apple.com/documentation/RealityKit/guided-capture-sample was fine with beta 3. In beta 4, getting these errors: Generic struct 'ObservedObject' requires that 'ObjectCaptureSession' conform to 'ObservableObject' Does anyone have a fix? Thanks
Replies
9
Boosts
2
Views
2.4k
Activity
Nov ’24
ImageRenderer on iOS - generates blurry image, .scale ineffective?
I'm getting a low quality image when using ImageRenderer on iOS16 both on simulator and device. i.e. when saving the rendered image to the Photo Library or sending to Notes.. it's very pixelated. Everything I read would suggest simply setting .scale but that appears to have no effect. I'm including a sample project. You can see the commented out sections which also fail. It would seem that scale is being ignored completely. Has anyone else experienced this? struct helloWorldView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundColor(.accentColor) Text("Hello, world!") } } } struct ContentView: View { @State private var screenshotimage: UIImage? @State private var screenshot: Bool = false @State private var showsharesheet: Bool = false @State private var sharescreenshot: Bool = false @State private var imageToShare: Image? var body: some View { NavigationStack { helloWorldView() .padding() .toolbar { ToolbarItem(placement: .primaryAction) { Button("Share") { showsharesheet.toggle() } } } .sheet(isPresented: self.$showsharesheet) { NavigationStack { ScrollView { Section { if screenshotimage != nil { Image(uiImage: screenshotimage!) ShareLink( item: Image(uiImage: screenshotimage!), preview: SharePreview( "Share Title", image: Image(uiImage: screenshotimage!) ) ) { Label("Share Image", systemImage: "square.and.arrow.up") .foregroundColor(.white) .padding() .background(.blue.gradient.shadow(.drop(radius: 1, x: 2, y: 2)), in: RoundedRectangle(cornerRadius: 5)) } } else { Text("Creating image..") } } } .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Dismiss") { showsharesheet = false } } } .navigationTitle("Preview") .navigationBarTitleDisplayMode(.inline) } .onAppear() { screenshot.toggle() } .onChange(of: screenshot, perform: { _ in // Task { let renderer = ImageRenderer(content:helloWorldView()) // renderer.scale = UIScreen.main.scale renderer.scale = 3.0 screenshotimage = renderer.uiImage // } }) } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
Replies
4
Boosts
3
Views
3.7k
Activity
Dec ’22