Problems with scaling
in
Programming Questions
•
2 years ago
Hi all ,
Am trying to change a scale the size of an image according to a parameter given by a user . The thing is the size of an image it seems never be changed after I input the parameter, I do not know why , am using NetBeans with processing
here is my code , if any one can help me, Thanks
Am trying to change a scale the size of an image according to a parameter given by a user . The thing is the size of an image it seems never be changed after I input the parameter, I do not know why , am using NetBeans with processing
here is my code , if any one can help me, Thanks
- /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package markerscaling;
import java.util.Scanner;
import processing.core.PApplet;
import processing.core.PImage;
/**
*
* @author tamara
*/
public class Main extends PApplet{
Scanner input =new Scanner(System.in);
public PImage marker;
public float cm;
public float cm2;
public int markerWidth;
public int markerHeight;
public static void main(String[] args)
{
PApplet.main(new String[]{"--present", "markerscaling.Main"});
// ArrayList<TableRecord>csvInputTableRecords= new ArrayList <TableRecord>();
// TODO code application logic here
}
@Override
public void setup()
{
marker= loadImage("25.png");
markerWidth= marker.width;
markerHeight=marker.height;
println("The size of the marker before scaling is"+ markerWidth+" "+ markerHeight);
float pixelPerInchOfWidth=markerWidth/72;
float pixelPerInchOfHight=markerHeight/72;
float pixelPerCmOfWidth= (pixelPerInchOfWidth / 2.54f);
float pixelPerCmOfHeight= (pixelPerInchOfHight / 2.54f);
System.out.print("Enter the size of am imaege");
float size= input.nextFloat();
cm =size*pixelPerCmOfWidth;
cm2=size*pixelPerCmOfHeight;
// scale(1.5f,1.5f);
println("the size of the marker after scaling is"+markerWidth+" "+ markerHeight);
size(markerWidth, markerHeight);
noLoop();
}
@Override
public void draw()
{
scale(markerWidth/cm, markerHeight/cm2);
image(marker,0,0);
save("marker.png");
}
public void KeyPressed()
{
redraw();
}
}
1