Re: Trying to print nsimage... What am I doing wrong?
Re: Trying to print nsimage... What am I doing wrong?
- Subject: Re: Trying to print nsimage... What am I doing wrong?
- From: Kyle Mandli <email@hidden>
- Date: Mon, 22 Jul 2002 18:20:32 -0500
What I have done in the past is a little bit simpler than what you seem
to be doing but the following is what I do
[image drawInRect:[self bounds] fromRect:imageRect
operation:NSCompositeCopy fraction:1.0];
where image is the NSImage and imageRect is the portion of the image
that is being drawn. If you want the entire image drawn in wherever you
are drawing to you would just pass [image size] like you have done with
pic NSImage. The NSImage class should then scale itself to draw into
the bounds passed onto to itself. If you are trying to make it scale
proportionally and you are doing something fairly basic with the image,
I would consider using the NSImageView class so it would do this for you
and then move the view itself. You can then subclass NSImageView for
some interaction or special drawing stuff. Good luck, I hope this helps.
Original Code:
picRect.origin.x = currentRect.origin.x;
picRect.size.width = currentRect.origin.x + 95.0;
imageSize = [pic size];
scaleFactor = picRect.size.width / imageSize.width;
picRect.size.height = imageSize.height * scaleFactor;
picRect.origin.y = currentRect.origin.y + currentRect.size.height -
picRect.size.height;
srcRect.size = [pic size];
[pic drawInRect:picRect fromRect:srcRect operation:nil fraction:0];
**********************************
Mandli Communications, Inc.
email@hidden
**********************************
_______________________________________________
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.