• 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
TIFFRepresentation giving me a tiff WITH an alpha
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TIFFRepresentation giving me a tiff WITH an alpha


  • Subject: TIFFRepresentation giving me a tiff WITH an alpha
  • From: Ben Mackin <email@hidden>
  • Date: Wed, 13 Nov 2002 17:29:30 -0800

If I do the following:

myPDFasData = [[NSData alloc] initWithContentsOfFile:[filesArray
objectAtIndex:fileNum]];
myPDF = [[NSPDFImageRep alloc] initWithData:myPDFasData];

[myPDF setCurrentPage:newDocPages];
image1 = [[NSImage alloc] init];
[image1 addRepresentation:myPDF];
data = [image1 TIFFRepresentation];
[data writeToFile:@"/here.tif" atomically:YES];

here.tif has an alpha channel, which I do not want.

If I create the tiff file myself (by converting the pdf to tif in preview),
the tif is generated with no alpha channel. So what I need to do now is
figure out how to get my tif file to be generated with no alpha (as it
shouldn't have one).

If I do the following, it seems to just ignore the alpha cannel, so I get an
image with no alpha, but it doesn't look correct (anywhere that should be
white has been filled in black for example):

NSBitmapImageRep *tempImagRep;

[myPDF setCurrentPage:newDocPages];
image1 = [[NSImage alloc] init];
[image1 addRepresentation:myPDF];

tempImagRep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:[image1 size].width
pixelsHigh:[image1 size].height
bitsPerSample:8
samplesPerPixel:3
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
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:
NSCompositeSourceAtop];
[myImage2 unlockFocus];

data = [myImage2
TIFFRepresentationUsingCompression:NSTIFFCompressionPackBits factor:0.0];
[data writeToFile:@"/here.tif" atomically:YES];

So if anyone has some thoughts on this one, please fire away.

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.

References: 
 >Scrollbar (From: Steve Mills <email@hidden>)

  • Prev by Date: Scrollbar
  • Next by Date: Re: Scrollbar
  • Previous by thread: Scrollbar
  • Next by thread: Re: Scrollbar
  • Index(es):
    • Date
    • Thread