• 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: NSImage -- getting raw bitmap data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage -- getting raw bitmap data


  • Subject: Re: NSImage -- getting raw bitmap data
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Sun, 3 Aug 2003 14:49:13 +0200

At 10:32 Uhr -0700 02.08.2003, Dennis C.De Mars wrote:
NSData* tiffData = [theImage TIFFRepresentation];
NSBitmapImageRep* bitMapRep = [NSBitmapImageRep imageRepWithData:tiffData];

ThanksA At worst this and bitmapData should let me do the conversion manually, like the IconFamily package seems to do it (didn't think about checking that before).

NSImageRep has some interesting methods for setting these parameters but I don't know if using them on a bitmap rep will cause any kind of conversion to take place. You could experiment.

No, according to the docs, these accessors are solely for providing information about the data, but they perform no conversion :-(

I guess I would have tried to do it the way you tried (drawing the image into a preformed bitmapimagerep). Don't know why that didn't work, but if you could post some code maybe we could suggest modifications.

OK, here goes. I create the NSBitmapImageRep:

unsigned char* planes[1] = { 0 };
NSBitmapImageRep* bir;

planes[0] = (char*) [myData bytes]; // myData = member var.
bir = [[[NSBitmapImageRep alloc] autorelease] initWithBitmapDataPlanes:planes
pixelsWide:32 pixelsHigh:32 bitsPerSample:1 samplesPerPixel:1
hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedBlackColorSpace
bytesPerRow:4 bitsPerPixel:1];

[myImage addRepresentation:bir]; // myImage = member var
[imageView setImage: myImage]; // imageView = IBOutlet

That works just fine and displays my Bitmap. And then I try to draw into it in:

-(IBAction) imageViewChanged: (id)sender
{
NSArray* reps = [myImage representations];

NSLog( @"# %d", [reps count] ); // This prints "# 1".

[myImage lockFocusOnRepresentation: [reps objectAtIndex:0]];
[[imageView image] dissolveToPoint: NSMakePoint(0,0) fraction:1];
[myImage unlockFocus];

[imageView setImage: myImage];
}

And this is where it gets weird: It draws a *color* image on top of my B/W image, and it doesn't change my image data one bit. So I guess it replaces my representation with another??
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: NSImage -- getting raw bitmap data
      • From: Marcel Weiher <email@hidden>
References: 
 >Re: NSImage -- getting raw bitmap data (From: "Dennis C.De Mars" <email@hidden>)

  • Prev by Date: Re: NSScanner problem...
  • Next by Date: Re: Fast User Switching in Panther...
  • Previous by thread: Re: NSImage -- getting raw bitmap data
  • Next by thread: Re: NSImage -- getting raw bitmap data
  • Index(es):
    • Date
    • Thread