Article View: adobe.photoshop.scripting
Article #1805Try to scale an image
From: Barbu_Bogdan
Date: Mon, 12 Jul 2004 15:28
Date: Mon, 12 Jul 2004 15:28
40 lines
2272 bytes
2272 bytes
Hi!
I try to scale an image, in a new image keeping the aspect ratio.
PX the height of the original image
PY the width of the original image
DimX the maximum width of the displayed image
DimY the maximum height of the displayed image
//calculates the scale factors
F1 = DimX/PX //This is the scale factor for width
F2= DimY/PY //This is the scale factor for height
F= min(1, min(f1, f2)) //This is the scale factor for the entire image
//calculates the dimension of the new image (this image will be display)
pdimx=(long)(f*rectWidth); //the width of the new image
pdimy=(long)(f*rectHeight); //the height of the new image
//sets the pixels for the new image
for (I=0;I<pdimx;I++) for(j=0;j<pdimy;j++) newImage[i][j]= OriginalImage[I*f][j*f]
��������������������������
This algorithm works if OriginalImage is defined as an Matrix.
For a filter plugin the OriginalImage is defined as (uint8*)pixels.
So, in this case, first I need to create the Matrix for the OriginalImage and then to call the algorithm for this Matrix; but this mean to create a for structure for the entire image
for (i=0;i<PX;i++) for(j=0;j<PY;j++) OriginalImage[i][j] = pixels++
If the original image has big dimesnios this algorithm i very slow.
I want to create something like this:
for (i=0;i<pdimx;i++) for(j=0;j<pdimy;j++) { new[i][j] = pixels++; pixels +=K; }
where K is some number depending on F (scale image factor), i, j.
But I did not find this number, yet!
Has anyone created something like this?How can I find the K number?
Bogdan.
Technical Details
Message-ID:
<3bb500e5.-1@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer01.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!webxShow Full Headers
Complete Article Headers
X-Google-Thread: f5839,75ce92a838a8e306,start X-Google-Attributes: gidf5839,public X-Google-Language: ENGLISH,ASCII From: Barbu_Bogdan@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer01.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.photoshop.scripting Subject: Try to scale an image Message-ID: <3bb500e5.-1@webx.la2eafNXanI> Date: Mon, 12 Jul 2004 08:28:49 -0700 Lines: 52 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit