Re: Java Cocoa question (NSImage overlays)
Re: Java Cocoa question (NSImage overlays)
- Subject: Re: Java Cocoa question (NSImage overlays)
- From: MT <email@hidden>
- Date: Wed, 30 Jun 2004 21:11:36 +0100
Hi,
This may not be exactly what you are after, but it composites two
images and writes some text onto it too. It's for changing the app
icon, but you can deconstruct it easily to find the bit that does the
work.
The code creates a new image, and simply draws the two images to it,
then writes some text for good measure.
I've used it in Cocoa Java apps, and can verify that it works fine. It
took me a while to figure it out too. Apple's docs aren't that helpful.
If you specifically want to write overlays to PDFs, check out the
'sips' command line tool, I think it does just that.
Cheers
Moray
NSImage NewImage = new NSImage(new NSSize(128,128));
NSImage Badge = NSImage.imageNamed("Badge");
NSImage IconImage = NSImage.imageNamed("NSApplicationIcon");
NewImage.lockFocus();
IconImage.compositeToPoint(new NSPoint(0,0),
NSImage.CompositeSourceOver);
Badge.compositeToPoint(new NSPoint(60,70),
NSImage.CompositeSourceOver);
NSAttributedString T =
CocoaCommon.makeAttributedString("TEXT","small-bold-white",20f);
NSGraphics.drawAttributedString(T, new NSPoint(95,84));
NewImage.unlockFocus();
NSApplication.sharedApplication().setApplicationIconImage(NewImage);
This is a Java question so I hope that someone will be able to help. I
have spent hours searching for a solution but with no luck so I am
hoping someone on this list will be able to help.
I have an application that grabs a page from a PDF and outputs it as a
GIF file; but now what I want to do is to 'draw' ontop of that image
before writing it out (like an overlay on top of the original PDF
page).
I create an NSImage object by adding an NSPDFImageRep but then I want
to draw say a rectangle onto that NSImage possibly with NSBezierPath.
I even tried to add multiple representations to the NSImage object
using:
addRepresentations()
but that did not create the effect I was hoping for (of merged layered
content).
I thought that I could create some kind of NSView and then add objects
to it and then render that into an NSImage and then combine the two
images (the pdf and the drawing) but that plainly doesn't work.
Can anyone help please? I have been going round and round in circles
for days.
Thank you.
I v a n ...
--
Ivan Markovic
SculptLight
http://www.sculptlight.com
Mobile: (+353) 87 2939256
Office: (+353) 1 2982205
Fax: (+353) 1 2966848
2 Airfield Drive,
Churchtown,
Dublin 14,
Ireland.
VAT: IE 9072482G
_______________________________________________
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.
_______________________________________________
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.