Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Zoom image with J2ME

Posted on 2006-05-09
8
Medium Priority
?
2,079 Views
Last Modified: 2008-01-09
Hi Expert,

I need zoom out or zoom in a image with J2ME,
Can you help me for this? I need some example codes.

Thanks in advance!
0
Comment
Question by:CongUan
  • 4
  • 2
6 Comments
 
LVL 30

Accepted Solution

by:
Mayank S earned 1000 total points
ID: 16645150
Look at how to implement zoom in and zoom out:

http://www.java-tips.org/content/view/544/73/

There is some code posted here for the same:

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=41&t=003875

There's a Map application here which implements zoom-in/ zoom-out and the source-code/ binaries are downloadble:

http://www.garret.ru/~knizhnik/En_Map.htm
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16645151
0
 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 1000 total points
ID: 16645317
Hi,

http://www.garret.ru/~knizhnik/En_Map.htm

And here is the Example too..

This Java tip implements Zoom in and zoom out feature on an Image (Image Zoomer). This tip may help game developers to add various new kinds of appearances in games. This may also be useful for customized J2ME applications developed for mobile handsets.

public Image ZoomIn(Image img) {
   
    Image outImg = null;
    int[] rgbOutput = null;
   
    Graphics g = null;
    int width = 0,height = 0;
   
    try{
       
        width = img.getWidth();
        height = img.getHeight();
        outImg  = Image.createImage(height,width);
        int rgbInput[]=new int[width*height];
        rgbOutput = new int[width*height];
        img.getRGB(rgbInput,0,width,0,0,width,height);
       
        int i,j,k,l;
        k=0;
        int tempArr[][]  = new int[height][width];
       
        for(i=0;i<height;i++)
            for(j=0;j<width;j++)
                tempArr[i][j] = rgbInput[k++];
       
        k=0;
        for(i=0;i<height;i++) {
            for(j=0;j<width;j++) {
                rgbOutput[k]= tempArr[j][i];
                k++;
            }
        }
        g = outImg.getGraphics();
       
    } catch(Exception e){}
   
    return outImg.createRGBImage(rgbOutput,height,width,true);
}

public Image zoomImage(Image img) {
   
    image outImg = null;
   
    int[] rgbOutput = null;
    Graphics g = null;
    int width = 0,height = 0;
   
    try {
       
        width  =  img.getWidth();
        height = img.getHeight();
       
        outImg  = Image.createImage(width<<1,height<<1);
       
        int rgbInput[]=new int[width*height];
        rgbOutput = new int[(width<<1)*(height<<1)];
       
        img.getRGB(rgbInput,0,width,0,0,width,height);
       
        int i,j,k;
        k=0;
        for(i=0;i<(height<<1);i+=2) {
            for(j=0;j<(width<<1);j+=2) {
                rgbOutput[i*(width<<1) + j] = rgbInput[k] ;
                rgbOutput[(i+1)*(width<<1) + j]  = rgbInput[k];
                rgbOutput[i*(width<<1) + j+1]  = rgbInput[k];
                rgbOutput[(i+1)*(width<<1) + j+1]  = rgbInput[k];
                k++;
            }
        }
       
        g = outImg.getGraphics();
    } catch(Exception e){}
   
    return outImg.createRGBImage(rgbOutput,width<<1,height<<1,true);
}  

R.K
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 30

Expert Comment

by:Mayank S
ID: 16645494
>> Hi,
>> http://www.garret.ru/~knizhnik/En_Map.htm

That is the same link as I posted.
0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 16648684
sorry for that,

but example i provided is different rt ?

R.K
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16655093
Yes.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question