|
|
How to put some images together?
|
|
|
|
Junior Member
Join Date: Oct 2000
Location: Germany
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
Junior Member
Join Date: Oct 2000
Location: Germany
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status:
Offline
|
|
any way you could post the code or sudo code for this?
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Oct 2000
Location: Germany
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status:
Offline
|
|
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!
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status:
Offline
|
|
one more question... how do i set a certain color(s) to be transparent?
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Oct 2000
Location: Germany
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Jun 2000
Location: New York, NY
Status:
Offline
|
|
will do... at work right now but i'll try it tonight... thanks again!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|