NSBitmapImageRep - how can I remove or reverse an alpha channel from tiff?

Below is some code I cobbled together to save a square preview of an image. I am looking to figure out how to remove or inverse an alpha channel mask from a tiff image, and could really use some help....
// I have been using 256.0 and 0.4 for the last 2 arguments, though feel free test with whatever.
- (NSString *)savePreview: (NSString *)filePath: (NSString *)saveFilePath: (NSString *)previewSize: (NSString *)compressionRatio {
NS_DURING
NSAutoreleasePool *memoryPool = [[NSAutoreleasePool alloc] init];
NSImage *myImage = [[NSImage alloc] initWithContentsOfFile: filePath];
if (myImage == nil) {
[myImage release];
NSLog(@"! Error loading image");
return @"! Error loading image";
NSImageRep *myRep = [[myImage representations] objectAtIndex: 0];
float hres = [myRep pixelsWide]/[myImage size].width;
float vres = [myRep pixelsHigh]/[myImage size].height;
float newWidth = [previewSize floatValue];
float newHeight = newWidth;
NSImage *thumbImage = [[NSImage alloc] initWithSize: NSMakeSize(newWidth, newHeight)];
NSAffineTransform *at = [NSAffineTransform transform];
[myImage setScalesWhenResized: YES];
float heightFactor = newHeight/[myImage size].height;
float widthFactor = newWidth/[myImage size].width;
float scale;
if(heightFactor > widthFactor) {
scale = widthFactor;
} else {
scale = heightFactor;
[at scaleBy: scale];
[thumbImage lockFocus];
[[NSGraphicsContext currentContext] setImageInterpolation: NSImageInterpolationHigh]; // NSImageInterpolationNone, NSImageInterpolationLow, NSImageInterpolationHigh
[myImage setSize: [at transformSize: [myImage size]]];
[myImage compositeToPoint: NSMakePoint((newWidth-[myImage size].width)/2 , (newHeight-[myImage size].height)/2) operation: NSCompositeCopy];
NSBitmapImageRep *bitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0, 0, [thumbImage size].width, [thumbImage size].height)];
[thumbImage unlockFocus];
[myImage release];
[thumbImage release];
NSData *bitmapData = nil;
NSNumber *factor = [NSNumber numberWithFloat: [compressionRatio floatValue]]; // The compression factor. Used only for JPEG files. The value is a float between 0.0 and 1.0, with 0.0 being the lowest and 1.0 being the highest. It’s set when reading in and used when writing out.
NSDictionary *props = [NSDictionary dictionaryWithObject: factor forKey: NSImageCompressionFactor];
bitmapData = [bitmapImageRep representationUsingType: NSJPEGFileType properties: props];
[bitmapData writeToFile: saveFilePath atomically: YES];
[bitmapImageRep release];
[memoryPool release];
return @"YES";
NS_HANDLER
NSLog(@"Exception occured : %@", localException);
return @"NO";
NS_ENDHANDLER
}

<bump>

Similar Messages

  • How can I remove my very old Apple ID from my Iphone 4S as I have created other apple IDs.The old one is still staying on my mobile but that email doesn't exist anymore. I cant rest my mobile as this email address is staying my icloud setting.

    Q:-
    How can I remove my very old Apple ID from my Iphone 4S. The old ID is still staying on my mobile but that email doesn't exist anymore. I cant rest my mobile as everytime i tried it asks ID password which I don't remember.

    Hello mushysun,
    Thanks for using Apple Support Communities.
    If you did not sign out of your Apple ID on your iPhone before creating a new one, then you will need to sign back in with your previous Apple ID and then sign out.  If you do not remember your password and do not have access to the email account, then you can reset your password by using the security questions.
    If you forgot your Apple ID password - Apple Support
    Have a great weekend,
    Alex H.

  • How can I remove all my preferences and settings from mail and do a clean install of mail app?

    How can I remove all my preferences and settings from mail and do a clean install of mail app?

    Open mail > Preferences > Accounts
    Select the account and click the minus button at the bottom of the column.
    Quit mail
    ~/Library/Preferences/com.apple.mail.plist move this file to the trash and empty it.
    ~/Library/Mail/ and move all of the items in that folder to the trash and then empty it.

  • How can I remove the repetitive multiple daily updates from Mozilla

    Hello
    How can I remove the repetitive multiple daily updates from Mozilla?
    Within a day, each day I get prompts as: Mozilla Firefox Update is ready to install at your computer.........then I do install and update it.......then after few minutes again it asks to update the same edition.........again after logging in back few hours later it prompts me again with the same request........IT IS VERY ANNOYING!
    Thank You,
    Gene

    ''the-edmeister [[#answer-683804|said]]''
    <blockquote>
    You could allow the update to proceed - that will stop Mozilla from asking if you want to update every time you launch Firefox, as is supposed to happen.
    Any particular reason that you don't want Firefox 35.0.1 to be installed?
    </blockquote>
    Hi The EDmeister,
    Thank you for your response.
    Nevertheless, I have to repeat that I have ALREADY INSTALLED the Firefox 35.0.1 in my computer and ALLOWED IT TO PROCEED.
    The same edition is prompting me back again, and again and again, within a day, each day. I get that annoying message at the top-right hand.
    I do not want to see it every time, multiple times a day, that is the issue here, unresolved!
    Best regards,
    Gene

  • How can I remove the photos without deleting them from the album?

    I am making a book in Aperture 3.  I want to change some of the pages that I have put together, and want to remove some of the photos from some of the pages, to put them on another page.  How can I remove the photos without deleting them from the album?

    As a follow-up, I have found that clicking on the photo in the book also highlights the photo on the strip below.  So, if you then hit delete, you will delete the photo from both the book page and the album (which is the book, the way I have it set up).  If you only want to delete it from the book page, you then have to un-click the photo on the strip below, or both will be deleted.  This seems unwieldy.  I deleted 6 photos from a page and found all of them gone from the album.  The only way that I can see to keep them in the album is to then unselect them from the bottom strip after selecting them fro the page.  This seems to call for an extra step. 
    Nancy

  • How can I remove a Creative Cloud Free membership from my account?

    Thanks in advance for any help.
    I have Creative Suite 6 installed.
    I started to use CC and decided I didn't want it anymore, so I let the account lapse this month.
    The computer automatically switched now to a Creative Cloud Free membership, but how can I remove this?
    Now when I launch Acrobat, for example, it asks me to renew my subscription. Well, I don't want to!
    Help!

    Cancel http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html
    You MAY need to uninstall the Cloud and run the Cleaner
    -http://helpx.adobe.com/creative-cloud/help/install-apps.html (and uninstall)
    -http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html
    You MAY also need to deactivate your old software and reinstall and activate again
    -Cloud takes over https://forums.adobe.com/thread/1584746

  • How can i remove manually oracle 10g express edition from vista

    hello
    i use windows vista
    how can i remove manually oracle 10 g express edition
    please help

    1. Uninstall all Oracle components using the Oracle Universal Installer (OUI).
    2. Delete the HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE key which contains registry entries for all Oracle products by using regedit.
    3. Delete any references to Oracle services/components in the following registry location: HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/. Looks for key entries that starts with “Ora” which are obviously related to Oracle.
    4. Reboot the workstation.
    5. Delete the ORACLE_BASE directory. (i.e C:\Oracle)
    6. Delete the C:\Program Files\Oracle directory.
    7. Empty the temp directory.
    8. Empty the recycle bin.
    have you done this?

  • How can I remove photos added to my iPad from my PC and laptop?

    How can I remove or edit photos added to my iPad from my PC and laptop?  New iPad.   Thanks!

    You use the same process that you used to get the photos on the iPad to begin with. Photos that were synced from your computer using iTunes can only be deleted by de-selecting them from the folder from where they were synced -  and then re-syncing.
    So that means that you have to connect your iPd to your computer, launch iTunes, select your iPad under the devices heading in the sidebar, click on the Photos Tab on the right and then uncheck the folder of photos that you synced to the iPad and then click on Apply in the lower right corner of iTunes.
    If you want to remove all of the photos, uncheck the Sync Photos From Heading and then click on Apply.

  • How can i remove a user name or account from the ipad?

    I purchased the iPad from a friend who never used it but entered a user name and profile.  When I try to load something from eBooks, it automatically defaults to the other user name and not mine and I don't know how to change it to my user name (email address).  How can I completely remove anything related to that other user name and info?

    Attach your iPad to your iMac and then in iTunes on the Mac use iTunes > File > Devices > Transfer Purchases

  • How can i remove a key and its value from properties file

    hi all,
    i want remove a particular key and associated value from the
    properties file. is their any standard way of doing?
    thanks inadvance
    daya

    hi,
    thanks
    i am able to remove the key,
    one more question how can avoid storing date and time
    in properties file.
    thanks
    daya

  • How can I remove a non=working windows partition from my mac?

    Alright so when I got my computer around 3 years ago my mom installed Windows on it. Sadly it didn't work and there was an uninstall so it uninstalled it, but now I have this 10 GB windows partition that's still there but I can't boot up on it and it's wasting 10 GB of my space. HOw can I get rid of it without risking of personal data (on my mac partition)

    Hi Midnight Pharaoh;
    Seeing as how I don't allow anything from Microsloth into my house I am not able to answer your question from personal experience but I believe that Boot Camp can in addition to creating a partition for Winders also delete said partition. If you need more details you might try reposting in the Boot Camp forum instead of the Snow Leopard forum.
    Allan

  • How can I remove a computer that I sold from iCloud?

    When I open ICloud I see my PC, my Iphone and an old Macbook Pro that I sold a while ago.
    How can I delete it?

    Hi jeffrey sg,
    When you convert a file, it's automatically stored in your Acrobat.com online account. You can download your files by following these steps:
    Log in to your account at https://cloud.acrobat.com/files.
    Select the file or files that you want to download.
    Click Download at the top of the Files list. Your files will be downloaded to the Downloads folder on your computer.
    Please let us know how it goes.
    Best,
    Sara

  • How can i remove all of the purchased songs from my phone?

    I want to remove all of the purchased songs from my phone, but I'm not having any success.  I've transferred the purchases to iTunes, and turned off the cloud on my phone, but they are still there.  They will not let me delete them...

    Roy631 wrote:
    They go away until the next sync and then they return to the list.  They are shown in iTunes greyed out with a broken circle in the first column when manually viewing them.
    It's an iPhone 5S, I'm running the latest OS, 8.1.
    OK, maybe time to get extreme.  I've had similar experiences, sometimes occurring after making direct-to-device purchases and sometimes after doing an iOS update.  In the two times I've experienced what you've seen I've fixed it by digging deeper, bear with me:
    If your iPhone is not set for manual management, do so. (i.e. select "Manually manage music and video")
    While connected to iTunes, navigate the contents of the iPhone.  Select all songs and delete them.  Ignore the gray ones if still present.
    Eject the iPhone and go to Settings/ General/ Usage/ Manage Storage.  Let the list populate then select the Music category.  In the next screen, swipe across "All Songs" from right to left and tap Delete.
    Connect back to iTunes, perform a backup, then restore the iPhone and reload the backup.
    Your iPhone should now have its settings, accounts, and apps back, but no music -- not even the "ghost" entries.  Add the music back that you want, either via manually dragging and dropping from iTunes, or auto-syncing all or a portion of your library.
    Some people reported luck with just step #3.  The problem I've had with that, is any music that I want remaining on the iPhone gets corrupted, such that playback will skip and/or show the wrong artwork.  By deleting all music first, then following up with a restore, that seems to clear the problem.  Personally I avoid direct-to-device purchases since I've had spooky occurrences almost every time where the purchases are very difficult to remove.

  • I dont know if this will be in the right forum, if its not feel free to move it, but i was only wondering how can i remove all my credit card info from my apple id account but still keep the account?

    basically what title says ^^^^ it on a iphone 4s

    Go to the store in iTunes and in the top right click on your account. You can add or remove payment info there.

  • How can I remove a mobile as a machine from firefox sync?

    I have 3 Windows PCs and an android phone, all running the latest firefox versions. All of them participate in firefox sync.
    Now, on the windows version, there is an option to disable/remove a machine from participation in syncing. This actually means that the relevant account is removed from the firefox sync servers.
    What is the equivalent on the Android version? I can see that there is an enable/disable sync toggle, but does this actually delete the mobile account as a machine from the firefox sync server storage?

    Cancel http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html
    You MAY need to uninstall the Cloud and run the Cleaner
    -http://helpx.adobe.com/creative-cloud/help/install-apps.html (and uninstall)
    -http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html
    You MAY also need to deactivate your old software and reinstall and activate again
    -Cloud takes over https://forums.adobe.com/thread/1584746

Maybe you are looking for

  • XML to Internal table using XSLT by CALL TRANSFORMATION error

    Dear experts, I have to fetch the data from an XML file using XSLT into internal tables. The XML file is very big as following:- <?xml version="1.0" standalone="yes" ?> - <Shipment>   <shipmentID>25091203S000778</shipmentID>   <manifestDateTime>2009-

  • How to avoid Moire Effects (jiggered still pictures) using iM and iDVD.

    This is a discussion going on forever and forever in this forum. I had the problem of bad looking slideshows myself, and I am hearing the same tips over and over again that just don't work. This is what I found out on how to avoid moire effects in yo

  • Can CMT Session Bean call BMP Entity Bean in WebLogic 6.0?

              Hi           Does anybody successfully use CMT Session Bean calling BMP +CMT Entity bean in           WebLogic6.0? I have the following problem.           Any idea will be appreciated.           --Winston           Let's say we have a Sessi

  • 20GB storage? why so little fr

    I recently bought a used NOMAD Jukebox 2 LX 20 GB on ebay. It works great and has been easy to figure out. My problem is that it says it is a 20GB, but with less than 00 songs loaded (most are mp3's, most in the 5 - 6 MB range) it says I have less th

  • How to display stored image in jsp  in ie7???

    i am using internet explore7. i have a problem when i am displaying an image in jsp its not properly coming. this image and image is stored in database. image is stored in database using "binarystream" . i am just simply calling the image path and us