Post not yet marked as solved
Under Sonoma 14.4 the compression option doesn't work with PNG images. It works for JPG/HEIF. Preview can export PNG file to HEIC with compression option. What am I missing? Previously this has worked. I am trying with 0.01 and 0.9 as compression quality and the file size is the same for PNG.
Is Preview using some trick to convert the image using ciContext.createCGImage?
PS: Compression option of 1.0 was broken under 14.4 RC and Preview created empty file.
func heifImageDataUsingDestination(at url: URL, compressionQuality : CGFloat) -> Data? {
guard let imageSource = CGImageSourceCreateWithURL(url as CFURL, nil) else { return nil }
guard let cgImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) else { return nil }
var mutableData = NSMutableData()
guard let imageDestination = CGImageDestinationCreateWithData(mutableData, "public.heic" as CFString, 1, nil) else { return nil }
let options = [ kCGImageDestinationLossyCompressionQuality: compressionQuality ] as CFDictionary
CGImageDestinationAddImage(imageDestination, cgImage, options)
let success = CGImageDestinationFinalize(imageDestination)
if success {
return mutableData as Data
}
return nil
}
func heifImageDataUsingCIContext(at url: URL, compressionQuality : CGFloat) -> Data? {
guard let ciImage = CIImage(contentsOf: url) else { return nil }
let context = CIContext()
let colorspace = ciImage.colorSpace ?? CGColorSpaceCreateDeviceRGB()
let options = [CIImageRepresentationOption(rawValue: kCGImageDestinationLossyCompressionQuality as String) : compressionQuality]
return context.heifRepresentation(of: ciImage, format: .RGBA8, colorSpace: colorspace, options: options)
}
Post not yet marked as solved
I just tried on macOS 14.0 Sonoma to load SVG and it works. There is no parity on iOS17. Is this officially supported and documented?
let xmlSVGImage = "<svg height=\"190\"><polygon points=\"100,10 40,180 190,60 10,60 160,180\" style=\"fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;\" /></svg>"
let svgData = xmlSVGImage.data(using: .utf8)!
let svgImage = NSImage(data: svgData)
print(svgImage)
Optional(<NSImage 0x600001400140 Size={185, 190} RepProvider=<NSImageArrayRepProvider: 0x600002704220, reps:(
"_NSSVGImageRep 0x60000063c1e0 Size={185, 190} ColorSpace=Generic RGB colorspace BPS=0 Pixels=0x0 Alpha=NO AppearanceName=(null)"
)>>)
Post not yet marked as solved
On iOS 14 I am using this format to get QR code correctly recognised and subject + body transferred to new email message:
mailto:__@_?subject=Hello&body
On iOS 15 this doesn't work.
Is there a new format to use?
Post not yet marked as solved
Since macOS Catalina I started to get report I can't reproduce but I know where is it crashing.Register rsi has following selector in memory:_controlStopTracking:at:inView:mouseIsUp:SEGV_MAPERR has address 0x000059b575cd55f8 which is a result of 0x000059b575cd55e0+0x18AppKit where it crashes:if (*(int8_t *)(var_90 + 0x18) != 0x0) {
[r14 _controlStopTracking:r15 at:sign_extend_64(*(int8_t *)(var_70 + 0x18)) inView:r8 mouseIsUp:r9];
}https://imgur.com/a/pXro4QFReports are coming from multiple systems/languages and I can't simulate the crash.How to report this or what can I do more (debugging)?Exception Type: SIGSEGV
Exception Codes: SEGV_MAPERR at 0x59b575cd55f8
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x00007fff64e2501d objc_msgSend + 29
1 AppKit 0x00007fff2c098af0 NSControlTrackMouse + 1491
2 AppKit 0x00007fff2c0984f4 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 129
3 AppKit 0x00007fff2c5d92b5 -[NSStepperCell trackMouse:inRect:ofView:untilMouseUp:] + 161
4 AppKit 0x00007fff2c3c86c4 -[NSDatePickerCell(NSTextFieldWithStepperDatePickerInternal) _textFieldWithStepperTrackMouse:inRect:ofView:untilMouseUp:] + 391
5 AppKit 0x00007fff2c097733 -[NSControl mouseDown:] + 747
6 AppKit 0x00007fff2c095b0d -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4906
7 AppKit 0x00007fff2bfffc5c -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2611
8 AppKit 0x00007fff2bfff005 -[NSWindow(NSEventRouting) sendEvent:] + 348
9 AppKit 0x00007fff2bffd37c -[NSApplication(NSEvent) sendEvent:] + 351
10 AppKit 0x00007fff2be490cf -[NSApplication run] + 706
11 AppKit 0x00007fff2be1b465 NSApplicationMain + 776
12 Dynaper 0x00000001071d9199 main (receigen.h:5142)
13 libdyld.dylib 0x00007fff6619f7fd start + 0Thread 0 crashed with x86_64 Thread State:
rflags: 0x0000000000010202 rax: 0x00007ffee8a765e8 rdi: 0x00006000018e55e0 r14: 0x00006000018e55e0
rsi: 0x00007fff2cadb39d r8: 0x0000000000000091 rdx: 0x00007f9e6cd39f10 r10: 0x000059b575cd55e0
cs: 0x000000000000002b fs: 0x0000000000000000 r9: 0x00000000000007fb r15: 0x00007f9e6cd39f10
rbx: 0x0000000000000000 r11: 0x00007fff2cadb39d rip: 0x00007fff64e2501d rbp: 0x00007ffee8a766b0
gs: 0x0000000000000000 rsp: 0x00007ffee8a76468 r12: 0x000060000088dd40 rcx: 0x0000000000000000
r13: 0x00006000018e45b0
Post not yet marked as solved
I am trying to use non-bordered pull down NSPopupButton in toolbar. The problem is the highlight which results in burning of the image. There is no burning when the NSPopupButton is bordered (however i have to subclass heavily to get the same effect). I tried to set numerous cell properties without effect. The only solution I have is to draw a substitute cell which has the same effect.How to draw the highlight the same way the NSButtonCell is doing@interface ToolbarPopUpButtonCell : NSPopUpButtonCell
@end@implementation ToolbarPopUpButtonCell- (void)drawImageWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSImage *image = [self image];
NSButtonCell *buttonCell = [[NSButtonCell alloc] initImageCell:image];
[buttonCell setHighlighted:[self isHighlighted]];
[buttonCell drawImage:image withFrame:cellFrame inView:controlView];
}@endExample (left - burning effect, right - nicer overlay)https://i.stack.imgur.com/13rUe.png
Post not yet marked as solved
I have noticed that the new Mojave wallpaper under macOS Catalina has been re-encoded for larger resolution and according to metadata it support tiles. I can drag out single TIFF images from preview and more info still shows the tile support for individual TIFF files. However, when I try to recreate HEIC file from those TIFF files I lose tile support. How to create HEIC image with tile support?NSMutableData *mData = [NSMutableData data];
CGImageDestinationRef destination;
destination = CGImageDestinationCreateWithData((CFMutableDataRef)mData, (CFStringRef)AVFileTypeHEIC, numberOfImages,NULL);
NSDictionary *options = @{(id)kCGImageDestinationLossyCompressionQuality: @(1.0),
(id)kCGImagePropertyTIFFTileWidth : @(1024), //-> no effect
(id)kCGImagePropertyTIFFTileLength : @(1024) //-> no effect};
CGImageDestinationAddImageAndMetadata(destination, imageRef, imageMetadata, (CFDictionaryRef)options);