• 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: Problem drawing directly to bitmap rep using NSGraphicsContext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Problem drawing directly to bitmap rep using NSGraphicsContext


  • Subject: RE: Problem drawing directly to bitmap rep using NSGraphicsContext
  • From: Vinay Prabhu <email@hidden>
  • Date: Wed, 29 Nov 2006 11:01:45 +0530
  • Importance: Normal

Hi,

My intention is to draw thumbnails of different images on another image.

For example pBitmapRep is created with the width and height of 1725x1725.
The container bitmap rep must be of 1725x1725, to calculate the position and
size of the
thumbnails.
pBitmapRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
                        pixelsWide:1725
                        pixelsHigh:1725
                        bitsPerSample:8
                        samplesPerPixel:4
                        hasAlpha:YES
                        isPlanar:NO
                        colorSpaceName:NSCalibratedRGBColorSpace
                        bitmapFormat:0
                        bytesPerRow:(4 * 1725)
                        bitsPerPixel:32];
Next step is to draw a background image(imageRep) on pBitmapRep, imageRep
can have any dimensions.
While trouble shooting, I have made sure that, the dimension of pBitmapRep
is greater than imageRep.
So imageRep can fit into pBitmapRep.

I have tried drawing using resolution of both the bitmap rep's
[imageRep drawInRect:NSMakeRect(0, 0, [imageRep pixelsWide], [imageRep
pixelsHifh])];
[imageRep drawInRect:NSMakeRect(0, 0, [pBitmapRep pixelsWide], [pBitmapRep
pixelsHifh])];
As drawInRect scales the image as required.

In both cases, only part of the imageRep is drawn onto the pBitmapRep.

Regards
Vinay

-----Original Message-----
From: Shawn Erickson [mailto:email@hidden]
Sent: Wednesday, November 29, 2006 2:08 AM
To: Vinay Prabhu
Cc: Cocoa-Dev (E-mail)
Subject: Re: Problem drawing directly to bitmap rep using
NSGraphicsContext


On 11/28/06, Vinay Prabhu <email@hidden> wrote:
> Hi,
>
> In my application I am trying to directly draw into the bitmap rep.
> The problem is only a fraction of the original image is drawn to the
> NSBitmapRep.
>
> Here is the code,
> [NSGraphicsContext saveGraphicsState]
> [NSGraphicsContext setCurrentContext:[NSGraphicsContext
> graphicsContextWithBitmapImageRep:pBitmapRep]];
>
> NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc]
initWithData:[NSData
> dataWithContentsOfFile:path]];
>
> [imageRep drawInRect:NSMakeRect(0, 0, [imageRep pixelsWide], [imageRep
> pixelsHifh])];
>
> [NSGraphicsContext restoreGraphicsState];
>
> What is wrong in this code?

Can you clarify what are you attempting to do?

-Shawn

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >Re: Problem drawing directly to bitmap rep using NSGraphicsContext (From: "Shawn Erickson" <email@hidden>)

  • Prev by Date: Re: Slightly OT: SIGKILL (force quit) and child process termination
  • Next by Date: exceptions, debug and deployment
  • Previous by thread: Re: Problem drawing directly to bitmap rep using NSGraphicsContext
  • Next by thread: Re: Problem drawing directly to bitmap rep using NSGraphicsContext
  • Index(es):
    • Date
    • Thread