Hello Christian,
I looking to change or set an image resolution with NSImageMBS. After looking
over apples doc the setsize property is to do this, however when I try doing
such nothing changes.
If I try this code in Xcode it works:
@interface NSImage (DPIHelper)
- (void) saveAsImageType: (NSBitmapImageFileType) imageType withDPI: (CGFloat)
dpiValue atPath: (NSString *) filePath;
@end
@implementation NSImage (DPIHelper)
- (void) saveAsImageType: (NSBitmapImageFileType) imageType withDPI: (CGFloat)
dpiValue atPath: (NSString *) filePath
{
NSBitmapImageRep *rep = [[self representations] objectAtIndex: 0];
NSSize pointsSize = rep.size;
NSSize pixelSize = NSMakeSize(rep.pixelsWide, rep.pixelsHigh);
CGFloat currentDPI = ceilf((72.0f * pixelSize.width)/pointsSize.width);
NSLog(@"current DPI %f", currentDPI);
NSSize updatedPointsSize = pointsSize;
updatedPointsSize.width = ceilf((72.0f * pixelSize.width)/dpiValue);
updatedPointsSize.height = ceilf((72.0f * pixelSize.height)/dpiValue);
[rep setSize:updatedPointsSize];
NSData *data = [rep representationUsingType: imageType properties: nil];
[data writeToFile: filePath atomically: NO];
However I want this to work from Xojo using mbscomplete and everything looks
good until I try to use nsimage.setsize the dpi of the image is never changed
as it does in Xcode. Even if I get the same values as in Xcode with xojo the
setsize part does seem to be doing anything.
Here my xojo code
dim b as BinaryStream
dim im as new NSImageMBS(pImgWMWorking)
dim pew, peh as Integer
dim ppw, pph, nsetW, nsetH as double
pew=pImgWMWorking.width
peh=pImgWMWorking.height
// next two lines does same as nssize makeSize
ppw=pew/100
pph=peh/100
nsetW = Ceil((72.0 * ppw)/300)
nsetH = Ceil((72.0 * pph)/300)
// up to this point all values are the same as returned in objective-c
code
im.setSize(nsetW,nsetH) // this does not seem to work ?
b=ffile.CreateBinaryFile("")
b.Write im.PNGRepresentation
b.close
I wondering if the NSImageMBS.setsize is either working correctly or if I am
missing something to get this to work. Any help is much appreciated.
Thanks for your time,
Cheers.
Obleo Beck
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
[email protected]
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info