Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How to put some images together?

How to put some images together?
Thread Tools
rudynorff
Junior Member
Join Date: Oct 2000
Location: Germany
Status: Offline
Reply With Quote
Aug 24, 2004, 11:56 AM
 
Hello,

I've got several PNGs that are transparent. I want to put them together to one NSImage so that I can add it to an NSImageCell inside a TableView.
I did something like this:
NSImage *anImage = [NSImage imageNamed:@"PictureOne"];
Now, I have my background image, but how do I put the transparent ones on top of them?

Kind regards
rudy
     
smeger
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Aug 24, 2004, 05:24 PM
 
Pick one of the images to be your destination image. -lockFocus on it and use the drawAtPoint or drawInRect selectors to draw the other images on top of it.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
rudynorff  (op)
Junior Member
Join Date: Oct 2000
Location: Germany
Status: Offline
Reply With Quote
Aug 25, 2004, 09:31 AM
 
Originally posted by smeger:
Pick one of the images to be your destination image. -lockFocus on it and use the drawAtPoint or drawInRect selectors to draw the other images on top of it.
Yes! It worked. Thank you very much!

Sincerely
rudy
     
poulh
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Apr 7, 2005, 12:48 PM
 
any way you could post the code or sudo code for this?
     
rudynorff  (op)
Junior Member
Join Date: Oct 2000
Location: Germany
Status: Offline
Reply With Quote
Apr 7, 2005, 01:10 PM
 
here, hope this works for you. if not just let me know, ok? i' not the cocoa pro but maybe i can help.


NSSize aSize = NSMakeSize(60.0,60.0);
NSImage *anImage = [[NSImage alloc] initWithSize:aSize];

NSImage *cloudImage =
[NSImage imageNamed:[[NSNumber numberWithInt:theClouds] stringValue]];

[anImage lockFocus]; // draw on this image
[cloudImage compositeToPoint:NSMakePoint(0,0) operation: NSCompositeSourceOver];
[anImage unlockFocus];


bye
rudy
     
poulh
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Apr 7, 2005, 03:40 PM
 
so the lockfocus method says "draw to this image instead of to the view"? what if i want to go back to drawing to the view?

thanks!
     
poulh
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Apr 7, 2005, 03:48 PM
 
one more question... how do i set a certain color(s) to be transparent?
     
rudynorff  (op)
Junior Member
Join Date: Oct 2000
Location: Germany
Status: Offline
Reply With Quote
Apr 7, 2005, 03:54 PM
 
Originally posted by poulh:
so the lockfocus method says "draw to this image instead of to the view"? what if i want to go back to drawing to the view? thanks!
well i havent been drawing to the view in my app. but i guess you could go back by saying [myView lockFocus]; or if you are in the view itself [self lockFocus]; have you actually tried that? if this doesnt work i will check in one of my books, but try that first ok?

bye
rudy
     
poulh
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status: Offline
Reply With Quote
Apr 7, 2005, 04:02 PM
 
will do... at work right now but i'll try it tonight... thanks again!
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:52 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,