• 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
Re: Scaling an NSImage makes the edges disappear.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scaling an NSImage makes the edges disappear.


  • Subject: Re: Scaling an NSImage makes the edges disappear.
  • From: "David Springer" <email@hidden>
  • Date: Thu, 21 Aug 2008 14:34:44 -0600

Hi Ken,

I can build a test app - give me a couple hours to put it together.

As for antialiasing, I thought that might be the problem, but I set
the image interpolation on the graphics context to
NSImageInterpolationNone and get the same results.

I am on Leopard 10.5.4 (this all has to work on Tiger, as well though).

Thanks
- Dave.S


On Thu, Aug 21, 2008 at 2:26 PM, Ken Ferry <email@hidden> wrote:
> Hi David,
>
> Could you post a complete test app? There's nothing in what you've
> posted that looks problematic[1].  Also, what OS are you working on?
>
> -Ken
>
> [1]: well, except maybe that you're likely to see antialiasing on the edges.
>  Your problem looks more severe than antialiasing, though.
>
> On Thu, Aug 21, 2008 at 12:47 PM, David Springer <email@hidden> wrote:
>> 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
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> 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:
>>
>> This email sent to email@hidden
>>
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >Scaling an NSImage makes the edges disappear. (From: "David Springer" <email@hidden>)
 >Re: Scaling an NSImage makes the edges disappear. (From: "Ken Ferry" <email@hidden>)

  • Prev by Date: Re: !foo vs foo == nil
  • Next by Date: Re: Modifying TextEdit.app
  • Previous by thread: Re: Scaling an NSImage makes the edges disappear.
  • Next by thread: Vancouver - We Need A Mac Guru @ macProVideo
  • Index(es):
    • Date
    • Thread