participate


CLDC and MIDP - Zoom In-Out Image
<<   Back to Forum  |   Give us Feedback
This topic has 1 reply on 1 page.
pravin_bluebird
Posts:59
Registered: 9/1/05
Zoom In-Out Image   
Jan 11, 2006 9:34 PM

 
Hi all,

I want to apply the Zoom-In Zoom- Out feature on an Image .

Can anyone help me ?.....

Thanks
 
iceman345
Posts:65
Registered: 11/23/05
Re: Zoom In-Out Image   
Jan 13, 2006 12:56 AM (reply 1 of 1)  (In reply to original post )

 
Are trying SEARCH here?

http://onesearch.sun.com/search/onesearch/index.jsp?qt=resize&subCat=siteforumid%3Ajava76%2Csiteforumid%3Ajava80%2Csiteforumid%3Ajava82&site=dev&dftab=siteforumid%3Ajava76%2Csiteforumid%3Ajava80%2Csiteforumid%3Ajava82&chooseCat=javaall&col=developer-forums

1) From SUN example

    private Image resize(Image image, int width, int height) {
        int sourceWidth = image.getWidth();
        int sourceHeight = image.getHeight();
                
        Image thumb = Image.createImage(width, height);
        Graphics g = thumb.getGraphics();
        
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                g.setClip(x, y, 1, 1);
                int deltaX = x * sourceWidth / width;
                int deltaY = y * sourceHeight / height;
                g.drawImage(image, x - deltaX, y - deltaY, Graphics.LEFT | Graphics.TOP);
            }
        }
        
        Image immutableThumb = Image.createImage(thumb);
        
        return immutableThumb;
    }


2: From this forum

private int[] reescalaArray(int[] ini, int x, int y, int x2, int y2) {
   int out[] = new int[x2*y2];
   for (int yy = 0;  yy < y2; yy++) {
     int dy = yy * y / y2;
     for (int xx = 0; xx < x2; xx++) {
       int dx = xx * x / x2;
       out[(x2*yy)+xx]=ini[(x*dy)+dx];         }       }
   return out;}
 
private Image getSmall(Image temp, int newX, int newY) throws Exception{
   //Need an array (for RGB, with the size of original image)
   int tX = temp.getWidth();
   int tY = temp.getHeight();
   int  rgb[] = new int[tX*tY];//Get the RGB array of image into  "rgb"
    temp.getRGB(rgb,0,tX,0,0,tX,tY);//Call to our function and obtain RGB2
    int rgb2[] = reescalaArray(rgb,tX,tY,newX,newY);//Create an image with that RGB array
    rgb = null;
    Image temp2 = Image.createRGBImage(rgb2,newX,newY,true);
    rgb2 = null;
    return temp2;
}
 
 
This topic has 1 reply on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 28
  • Guests : 133

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums