Folks,

For some reason, I am not able to figure this out.  I want to draw a
scaled NSImage, but the edges of the image are not drawn, it seems
like the resizing actually clips the image.

I have an NSBitmapImageRep created from some data.  I then create the
NSImage like this:

NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([myBitmap
pixelsWide], [myBitmap pixelsHigh]);
[image addRepresentation:myBitmap];
[image setScalesWhenResized:YES];

// Figure out the new image size so that it is proportionally scaled
by |scaleFactor|.
NSSize scaledSize = ProportionallyScale([image size], scaleFactor);
    [image drawInRect:NSMakeRect((kTileImageSize - scaledSize.width) * 0.5,
                                   (kTileImageSize - scaledSize.height) * 0.5,
                                   scaledSize.width,
                                   scaledSize.height)
               fromRect:NSZeroRect
              operation:NSCompositeSourceOver
               fraction:1.0];

This sometimes works (that is, the entire original image is visible).
But more often than not, the edges of the original image are not
drawn.  See the screen shots for a picture of what I get.

What am I doing wrong here?  I have scoured the archives, I have tried
things like making sure scaledSize has integer values, I have even
done crazy things like add one to the height just to see what would
happen.  Note that if I write out the TIFFRepresentation of |image|
(both before and after) the entire image gets into the file (that is,
the edges are not clipped).

In the attached picture, the top tile is correct (you see all the
black edges), the bottom two tiles are incorrect (not all the black
edges are visible).

Help?
Thanks!
- Dave.S

<<attachment: badthumbs.tiff>>

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to