Retina imaging problems with imaging

I ran into problems when working on the retina display. The size of NSImage is correct, but if I create an NSBitmapImageRep from it and write it to a file, I get the size of the witch twice as large as the original image. There is no such problem when I use it when displaying no retina.

  • I am creating NSImage from a file (1920x1080)
  • I draw some drawings on
  • I am creating an NSBitmapImageRep from a picture with pictures
  • I am writing it to a file
  • I get an image with dimensions 3840x2160

What can cause this?


NSImage *originalImage = [[NSImage alloc] initWithContentsOfURL:fileUrl];

NSImage *editedImage = [[NSImage alloc] initWithSize:originalImage.size];

[editedImage lockFocus];
//I draw here NSBezierPaths
[editedImage unlockFocus];

NSBitmapImageRep *savingRep = [NSBitmapImageRep imageRepsWithData:[editedImage TIFFRepresentation]];
NSData *savingData = [savingRep representationUsingType: NSPNGFileType properties: nil];
[savingData writeToFile:desiredFileLocationAndName atomically:no];

If I open an image and save it without editing, I get the correct image size

NSImage *imageFromFile = [[NSImage alloc] initWithContentsOfURL:fileURL];
NSBitmapImageRep *newRepresentation = [[NSBitmapImageRep imageRepsWithData:[imageFromFile TIFFRepresentation]];
NSData *savingData = [newRepresentation representationUsingType: NSPNGFileType properties: nil];
[savingData writeToFile:desiredFileLocationAndName atomically:no];
+5
source share
1 answer

. . NSImage , 2 . , .

0

All Articles