| | |
image processing
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Yes if you do down scale, function will reduce number of pixels and work out colour for each remaining pixel. Where if you scale up (enlarge) it will just spread the colour difference from pixel one to pixel two on the extra pixel received from enlragment
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Nov 2007
Posts: 31
Reputation:
Solved Threads: 0
i used the following code
public void actionPerformed(ActionEvent e)
{
int i,j,k,w,h;
double w_scale=1.0,h_scale=1.0;
drawimage=2;
byte[] comp = {0 , -1};
IndexColorModel cm = new IndexColorModel(2,2,comp,comp,comp);
BufferedImage temp1=new BufferedImage(15,15,BufferedImage.TYPE_BYTE_INDEXED,cm);
for(k=0;k<characters.size();k++)
{
BufferedImage temp=(BufferedImage)characters.get(k); //characters is ArrayList
w=temp.getWidth();
h=temp.getHeight();
if(w>=15 && h>=15)
{
w_scale=15/w;
h_scale=15/h;
}
else if(w<15 && h>=15)
{
w_scale=1.0;
h_scale=15/h;
}
else if(w<15 && h<15)
{
h_scale=15/h;
w_scale=1.0;
}
else if(w>=15 && h<15)
{
w_scale=15/w;
h_scale=15/h;
}
AffineTransform t=new AffineTransform();
t=AffineTransform.getScaleInstance(w_scale,h_scale);
Graphics2D g=temp1.createGraphics();
g.drawImage(temp,t,null);
g.dispose();
small_list.add(temp1);
repaint();
}
}
public void actionPerformed(ActionEvent e)
{
int i,j,k,w,h;
double w_scale=1.0,h_scale=1.0;
drawimage=2;
byte[] comp = {0 , -1};
IndexColorModel cm = new IndexColorModel(2,2,comp,comp,comp);
BufferedImage temp1=new BufferedImage(15,15,BufferedImage.TYPE_BYTE_INDEXED,cm);
for(k=0;k<characters.size();k++)
{
BufferedImage temp=(BufferedImage)characters.get(k); //characters is ArrayList
w=temp.getWidth();
h=temp.getHeight();
if(w>=15 && h>=15)
{
w_scale=15/w;
h_scale=15/h;
}
else if(w<15 && h>=15)
{
w_scale=1.0;
h_scale=15/h;
}
else if(w<15 && h<15)
{
h_scale=15/h;
w_scale=1.0;
}
else if(w>=15 && h<15)
{
w_scale=15/w;
h_scale=15/h;
}
AffineTransform t=new AffineTransform();
t=AffineTransform.getScaleInstance(w_scale,h_scale);
Graphics2D g=temp1.createGraphics();
g.drawImage(temp,t,null);
g.dispose();
small_list.add(temp1);
repaint();
}
}
Last edited by gauravmishra; Feb 29th, 2008 at 2:20 am.
Did it work or you having some problems with it?
PS: When posting code please use tags. In advanced options press hash sign "#" and that will automaticaly insert these tags for you. Just simple place your code between them
PS: When posting code please use tags. In advanced options press hash sign "#" and that will automaticaly insert these tags for you. Just simple place your code between them
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Code for Image Processing (C)
- image processing (Graphics and Multimedia)
- image processing project (VB.NET)
- Image processing using C++ (C++)
- image processing in C (C++)
- image processing (C#)
Other Threads in the Java Forum
- Previous Thread: Removing a specific item from a linked list
- Next Thread: Windows authentication using java
Views: 890 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for Java
-xlint android api apple applet application arguments array arrays automation binary block bluetooth chat class classes client code compile component database developmenthelp draw eclipse encode error event exception file fractal freeze game gameprogramming givemetehcodez graphics gui helpwithhomework html ide image input integer iphone j2me j2seprojects java javac javaprojects jmf jni jpanel julia lego linux list loop loops mac map method methods mobile netbeans newbie notdisplaying number object online oracle print problem program programming project recursion scanner screen server set singleton size sms socket sort sql string swing system template test textfields threads time title transfer tree tutorial-sample update windows working






