Re: Resizing images
Re: Resizing images
- Subject: Re: Resizing images
- From: Simon McLean <email@hidden>
- Date: Mon, 4 Feb 2008 16:55:09 +0000
You can use QT4J. Here are some code snippets to put you on the right
track...
// opens, scales and saves images again.
QTSession.open();
QTFile file1 = new QTFile(location);
GraphicsImporter gi1 = new GraphicsImporter(file1);
Matrix matrix = new Matrix();
MediaUtilities.scaleImage(gi1, matrix, 200, 200);
GraphicsExporter exporter = new GraphicsExporter
(StdQTConstants.kQTFileTypeJPEG);
exporter.setInputGraphicsImporter(gi1);
exporter.setOutputFile(file1);
exporter.doExport();
QTSession.close();
// scales the given image if width or height is greater then max
width and height passed in
static public void scaleImage(GraphicsImporter gi, Matrix matrix,
int maxWidth, int maxHeight) {
try {
QDRect bounds = gi.getBoundsRect();
// maxWidth or maxHeight / x and y gives scaling factor for x and y
float currentX = bounds.getWidth();
float currentY = bounds.getHeight();
float scaleX = 1f;
float scaleY = 1f;
if (currentX > maxWidth) {
scaleX = (maxWidth / currentX);
}
if (currentY > maxHeight) {
scaleY = (maxHeight / currentY);
}
matrix.scale(scaleX, scaleY, 0, 0);
gi.setMatrix(matrix);
} catch (StdQTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Simon
On 4 Feb 2008, at 16:47, Mike Schrag wrote:
I use a JNI wrapper around OS X's CoreImage/ImageIO ... It kicks
the butt (by at least an order of magnitude and sometimes more) of
any other method on OS X.
ms
On Feb 4, 2008, at 11:31 AM, Miguel Arroz wrote:
Hi!
Just to know, what library do you use to manipulate images
(getting X and Y size, resizing, etc)? Do you use the standard
Java stuff, or anything else better/faster?
Yours
Miguel Arroz
Miguel Arroz
http://www.terminalapp.net
http://www.ipragma.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mdimension.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden