Re: TIFFRepresentation giving me a tiff WITH an alpha
Re: TIFFRepresentation giving me a tiff WITH an alpha
- Subject: Re: TIFFRepresentation giving me a tiff WITH an alpha
- From: Marco Binder <email@hidden>
- Date: Fri, 15 Nov 2002 14:04:51 +0100
Well, I agree, it should work as you assumed (actually using your
NSBitmapImageRep with all its settings). I dont know why it doesnt, but
given the fact, THAT it doesnt, you will have to strip the
alpha-channel manually. I have sent you some code already which should
allow you to do so, especially now that you precisely know what
configuration your image1 is.
It may be a pain in the *** to manipulate you raw pixel data, but it
will definitly work.
Your problem with "black what should be white" may boil down to the
fact, taht what is white is not actually white but R,G,B = 0,0,0 just
at alpha 0 which makes it transparent and you got a white background
"below" your image. If you now save it without alpha, it s just 0,0,0 =
black. You ll then have to catch this case (R=0, G=0, B=0, alpha=0) and
set the pixel value in your new imageRep to 255 = white.
I dont have your source-code, neither do I have the image you try to
convert, so all that is just a guess. at any rate, accessing the bitmap
data directly will let you do whatever you want.
marco
Am Freitag, 15.11.02 um 00:32 Uhr schrieb Ben Mackin:
On 11/13/02 8:27 PM, "Scott Anguish" <email@hidden> wrote:
I'm not sure how youc an get alpha in the final image if you don't
have alpha enabled in the bitmapimagerep
Well after doing some testing, it looks like it is ignoring what I
tell the
NSBitmapImageRep to be. Somewhere along the line, it is getting
overwritten
and using some different values.
Using the following code:
tempImagRep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:[image1 size].width
pixelsHigh:[image1 size].height
bitsPerSample:8
samplesPerPixel:1
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSCalibratedWhiteColorSpace
bytesPerRow:0
bitsPerPixel:0];
[tempImagRep setSize:[image1 size]];
NSImage *myImage2 = [[NSImage alloc] initWithSize:NSMakeSize([image1
size].width, [image1 size].height)];
[myImage2 addRepresentation:tempImagRep];
[myImage2 lockFocusOnRepresentation:tempImagRep];
[image1 compositeToPoint:NSMakePoint(0, 0) operation:NSCompositeCopy];
[myImage2 unlockFocus];
Something in there resets my NSBitmapImageRep, because I am getting a
RGB
image WITH an alpha channel (when I should be getting a 1 channel
greyscale
image...) Even if I have it set to samplesPerPixel=3 and
colorSpaceName=NSCalibratedRGBColorSpace, I still get the alpha
channel.
I also tried using drawInRect (instead of compositeToPoint) to see if
that
made a difference, but I get the same result.
So if anyone has some thoughts on how to save an image with no alpha,
please
speak up. I am totally at a loss now.
Thanks,
Ben
_______________________________________________
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.
--
|\ /| E-Mail: email@hidden WWW: www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
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.