• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Printing: getting the resolution right
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Printing: getting the resolution right


  • Subject: Printing: getting the resolution right
  • From: Herbert Putteneers <email@hidden>
  • Date: Thu, 24 Nov 2005 11:58:56 +0100

The following code (from Sketch) always produces results at screen resolution, even when printing.
When I arrive here, the only imagerep available for the image is an NSCachedImagerep, so I checked if somehow the image was unable to get the original data.
bmi = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]] does however give the correct result.


The problem seems to come from the off-screen window creation statement:
_cachedImage = [[NSImage allocWithZone:[self zone]] initWithSize:bounds.size];


This seems to always result in an image at screen-resolution. Is it possible to force this to a higher bit depth, or should I use a different approach?


- (void)drawInView:(SKTGraphicView *)view isSelected:(BOOL)flag { NSRect bounds = [self bounds]; NSImage *image;

image = [self transformedImage];
if (image) {
[image compositeToPoint:NSMakePoint(NSMinX(bounds), NSMaxY (bounds)) operation:NSCompositeSourceOver];
}
[super drawInView:view isSelected:flag];
}


- (NSImage *)transformedImage {
	if ([NSGraphicsContext currentContextDrawingToScreen] == NO)
		[self SKT_clearCachedImage];
    if (!_cachedImage) {
        NSRect bounds = [self bounds];
        NSImage *image = [self image];
        NSSize imageSize = [image size];

        if (NSEqualSizes(bounds.size, imageSize)) {
            _cachedImage = _image;
        } else if (!NSIsEmptyRect(bounds)) {
            BOOL flippedHorizontally = [self flippedHorizontally];
            BOOL flippedVertically = [self flippedVertically];

_cachedImage = [[NSImage allocWithZone:[self zone]] initWithSize:bounds.size];
if (!NSIsEmptyRect(bounds)) {
// Only draw in the image if it has any content.
[_cachedImage lockFocus];


if (flippedHorizontally || flippedVertically) {
// If the image needs flipping, we need to play some games with the transform matrix
NSAffineTransform *transform = [NSAffineTransform transform];
[transform scaleXBy:([self flippedHorizontally] ? -1.0 : 1.0) yBy:([self flippedVertically] ? -1.0 : 1.0)];
[transform translateXBy:([self flippedHorizontally] ? -bounds.size.width : 0.0) yBy:([self flippedVertically] ? -bounds.size.height : 0.0)];
[transform concat];
}


[[image bestRepresentationForDevice:nil] drawInRect:NSMakeRect(0.0, 0.0, bounds.size.width, bounds.size.height)];
[_cachedImage unlockFocus];
}
}
}
return _cachedImage;
}




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: GCC 4 Failed during compiling with a framework :(
  • Next by Date: Is NSBrowser suitable for this?
  • Previous by thread: Re: Bundle question..
  • Next by thread: Is NSBrowser suitable for this?
  • Index(es):
    • Date
    • Thread