Simple image enlarge/zoom

Hi
I need a way to resize or zoom in a png/jpg image in j2me. I am fairrly new to j2me and have been reading a few books but I am no proffesional.
Could someone post a midlet that does that. A COMPLETE midlet with imports and all, I have collected quite alot of pieces of code from the net but I have no idea how to put them into a midlet lol!
Any assistance would be appreciated I just need an application that takes an image located in the jar file and zooms/enlarges it to a size that I want.
Here are some of the codes i got from the net, but I dont really understand that much.
public static Image resizeImage(Image src, int screenWidth, int screenHeight) 
    int srcWidth = src.getWidth(); 
    int srcHeight = src.getHeight(); 
    Image tmp = Image.createImage(screenWidth, srcHeight); 
    Graphics g = tmp.getGraphics(); 
    int ratio = (srcWidth << 16) / screenWidth; 
    int pos = ratio / 2; 
    // Horizontal Resize 
    for (int x = 0; x < screenWidth; x++) 
        g.setClip(x, 0, 1, srcHeight); 
        g.drawImage(src, x - (pos >> 16), 0, Graphics.LEFT | Graphics.TOP); 
        pos += ratio; 
    Image resizedImage = Image.createImage(screenWidth, screenHeight); 
    g = resizedImage.getGraphics(); 
    ratio = (srcHeight << 16) / screenHeight; 
    pos = ratio / 2; 
    //Vertical resize 
    for (int y = 0; y < screenHeight; y++) { 
        g.setClip(0, y, screenWidth, 1); 
        g.drawImage(tmp, 0, y - (pos >> 16), Graphics.LEFT | Graphics.TOP); 
        pos += ratio; 
    return resizedImage; 
}  another one is
  * This methog resizes an image by resampling its pixels
  * @param src The image to be resized
  * @return The resized image
  private Image resizeImage(Image src) {
      int srcWidth = src.getWidth();
      int srcHeight = src.getHeight();
      Image tmp = Image.createImage(screenWidth, srcHeight);
      Graphics g = tmp.getGraphics();
      int ratio = (srcWidth << 16) / screenWidth;
      int pos = ratio/2;
      //Horizontal Resize       
      for (int x = 0; x < screenWidth; x++) {
          g.setClip(x, 0, 1, srcHeight);
          g.drawImage(src, x - (pos >> 16), 0, Graphics.LEFT | Graphics.TOP);
          pos += ratio;
      Image resizedImage = Image.createImage(screenWidth, screenHeight);
      g = resizedImage.getGraphics();
      ratio = (srcHeight << 16) / screenHeight;
      pos = ratio/2;       
      //Vertical resize
      for (int y = 0; y < screenHeight; y++) {
          g.setClip(0, y, screenWidth, 1);
          g.drawImage(tmp, 0, y - (pos >> 16), Graphics.LEFT | Graphics.TOP);
          pos += ratio;
      return resizedImage;
  }//resize image  if these were complete midlets it would be easy and quick for me to understand.
Thanx

here's a piece of code i use .
This is the class that is used to resize the image
public class St3ph3n {
    public St3ph3n() {
    public static int[] scale(int[] srcImage,int dataWidth,int dataHeight) {
        //Preallocating heap-size
        int x, y, b, d, e, f, h, e0, e1, e2, e3, x0, x1, y0, y1, y_width, x_multi,
y_multi, width_multi;
        int[] dstImage = new int[srcImage.length * 4];
        //Walking array
        for (x = 0; x < dataWidth; x++) {
            for (y = 0; y < dataHeight; y++) {
                //Get old pixel
                x0 = Math.max(0, x - 1);
                x1 = Math.min(dataWidth - 1, x + 1);
                y0 = Math.max(0, y - 1);
                y1 = Math.min(dataHeight - 1, y + 1);              
                y_width = y * dataWidth;
                b = srcImage[x + (y0 * dataWidth)];
                d = srcImage[x0 + y_width];
                e = srcImage[x + y_width];
                f = srcImage[x1 + y_width];
                h = srcImage[x + (y1 * dataWidth)];
                //Calculate new pixel
                if (b != h && d != f) {
                    e0 = (d == b) ? d : e;
                    e1 = (b == f) ? f : e;
                    e2 = (d == h) ? d : e;
                    e3 = (h == f) ? f : e;
                } else {
                    e0 = e;
                    e1 = e;
                    e2 = e;
                    e3 = e;
                //Set new pixel
                x_multi = x << 1;
                y_multi = y << 1;
                width_multi = dataWidth << 1;
                dstImage[x_multi + y_multi * width_multi] = e0;
                dstImage[x_multi + 1 + y_multi * width_multi] = e1;
                dstImage[x_multi + (y_multi + 1) * width_multi] = e2;
                dstImage[x_multi + 1 + (y_multi + 1) * width_multi] = e3;
        return dstImage;
}and here's how you use it
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class St3ph3nTest extends MIDlet
Image original;
Image Scaled;
Display display;
Form frm;
public St3ph3nTest()
display=Display.getDisplay(this);
frm=new Form("Test Scale");
try{
    original= Image.createImage("/res/test.png");
  }catch(Exception ee)
   int [] imageData = new int[original.getHeight()*original.getWidth()];
original.getRGB(imageData, 0, original.getWidth(), 0, 0, original.getWidth(), original.getHeight());
  int[] bigImageData = St3ph3n.scale(imageData, original.getWidth(), original.getHeight());
  Scaled= Image.createRGBImage(bigImageData, original.getWidth()*2, original.getHeight()*2, true);
protected void startApp()
frm.append(original);
frm.append(Scaled);
display.setCurrent(frm);
protected void pauseApp()
protected void destroyApp(boolean uc)
}cheers

Similar Messages

  • Help needed with simple image enlargement when viewing a gallery

    Hi
    I have a gallery component linked to a data thumb list. This all scrolls fine and works. When someone clicks on a thumb it shows the
    image larger. Then I would like it if you click on the larger image it fills the height of the page to see an even bigger view. I have managed to do this but some of the buttons do not work in the area were this image is even if the image is not showing and the image will not go back to its off state even though it has an interaction to do so. If I drag the image component down the layers panel so it is behind all the other bits on my page it all works, the image enlarges and disappears so the previous state is shown. The problem with this is I want the image to cover everything behind it, not be behind everything. I have included a couple of screen grabs just to give you an idea.
    sc 1 simple data list and image component
    sc2 Enlarged image but can not get it to go
    sc3 enlarged image can come and go no changes except I have moved the layer panel down
    to the bottom
    Any ideas how I can get this to work properly would be much appreciated
    many thanks

    I have sorted this out. There might be other ways of doing this but I added a button to the large image gallery component.
    constructed a rectangle the same size as the large image and set the opacity to 0. The whole area is now a button you can not see.
    One click anywhere on the image removes it with an interaction back to the first state which is off.
    hope this help anyone

  • Simple image rotation

    Hi all,
    Have a couple of pages on a site i'm building where i need a simple image rotation / image swap.
    It doesn't have to be anything flash, it's purely for a 200px square image to automatically swap every 5 seconds or so. It doesn't need any user buttons to go to next / previous, or enlarge when clicked.
    I've tried a couple of free jquery ones, but these won't load the starting image until all the images have been loaded into the browser, so you end up with a blank spot, then after say 10 seconds the images appear.
    Looking through the programs forums, it seems that the jquery i'm downloading isn't configurable to preload the images, so maybe i'm going down the wrong route completely!
    Whats the best / simplest way to do this and can you recommend anywhere to read up on how to implement it?
    Thanks
    Dan

    Dan, download the cycle plugin pack first: http://jquery.malsup.com/cycle/download.html. You can copy/ paste in a new .js file and store it locally on your site folder. Or, you could also use the cloud link as I've given below. Both will work.
    Then, include the jQuery library to before closing your </head> tag:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
    Now, include the jQuery cycle plugin library before your </head> tag:
    <script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script>
    Define the DIV that will animate with cycle plugin before your </head> tag:
    <script type="text/javascript">
    $(document).ready(function() {
        $('.slideshow').cycle({
    fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    </script>
    In the above code, Div with class slideshow will keep cycling with a fade effect. Note that for some effects to work, you may require the jquery easing plugin. But, fade will do just fine for your original question.
    Then, structure your image container:
    Based on your original code:
    <p class="pagetext">    <img src="images/hgsindeximg1.png" alt="School pupils" width="300" height="233" class="fltrt">Welcome  to our school website, we hope that you enjoy looking around the site. <br>
        </p>
    You have to restructure it this way:
    <p class="pagetext">
    <div class="slideshow">
    <img src="images/hgsindeximg1.png" alt="School pupils" width="300" height="233" class="fltrt">
    <img src="images/hgsindeximg2.png" alt="School pupils" width="300" height"233" class="fltrt">
    <img src="images/hgsindeximg3.png" alt="School pupils" width="300" height"233" class="fltrt">
    </div>
    Welcome  to our school website, we hope that you enjoy looking around the site. <br>
        </p>
    In the above code, I've added 2 more images that will rotate on your page. Change the filenames to whatever you desire. Also, ensure you retain the image dimensions same across all 3 images for best results.
    If you notice, I've just moved the images into a DIV called 'Slideshow'. As defined previously, all 3 images with <img..> within the div with class slideshow will keep rotating.
    On a sidenote, please please please please change the background color from red to something 'non-distractive'! Seriously, I went searching for moisturizing drops for my eyes once I opened up the test page you had posted!
    Trust this helps.

  • Premiere Pro - Assembling a Simple Image/Audio Video

    Hello,
    I am attempting to put together a brief video usind Premiere Pro with simple images and voice over, and am finding myself quite stuck.
    Is there a "best" image type to import into Premiere to avoid losing quality? If so, what is it?
    My images are 7.5x4" or smaller, and are not very high resolution. Is there a setting or video format to use that will best accomodate these images?
    Thanks.

    What is the intended destination for the completed video? If DVD, then use a DV sequence in Premiere (720x480 pixels). Choose standard (4:3) or Widescreen (16:9) option. You described your photos in inches. Are you scanning hard copies? If so, you could scan at 150dpi and that would provide adequate resolution for a DV project. If you wanted to go with HD, such as 720p for YouTube, then scan at 300dpi. A benefit of having photos a bit larger than the Sequence is that you can "zoom and pan" around in the image without losing quality, ala "Ken Burns Effect".
    If your images are already digital, then the "inches" are irrelevant - what are the dimensions in pixels? That is what we are concerned with.
    Thanks
    Jeff Pulera
    Safe Harbor Computers

  • Multiple image upload CRASH!!! but works with simple image upload

    I'm getting MAD.
    I'm using php and GD
    While the simple image and re size works like a charm, the multiple image upload or the multiple file upload have a strange behavior.
    It opens the pop-up with flash, then eventually shows me files or thumbnails but when I try to up load I just wait and get the typical "system becoming unstable" flash error.
    As I can see the directory is always generated (I've tried also to put a static directory) but after stargin the upload the flash uploader just crashes and no result.
    Any help would be really appreciated

    Hi Fonzie,
    as the folder is getting created, the issue you´re having is not related to wrong folder permission - it´s something else...
    As I wrote before, che common upload and resize function works perfectly
    this one works perfectly, because it´s just one file to upload and to process, wheras doing that with multiple files might collide with some settings on your server
    So for sure it's not a simple issue as the max filesize
    Are you sure ? Did you check the current "max_upload_filesize" setting ? As long you don´t check it, you can´t know :-)
    As a general rule of thumb, it´s important to be aware of the fact that uploading & resizing images on the server might collide with several PHP settings -- and the more images you upload and resize in one swoop, the closer you´re getting to these limits respectively might even be exceeding them. The following "directives" are those which have an effect on whether your image/file upload & processing will work or not:
    - "max_upload_filesize" :: is sometimes set to just 8 MB on a shared hosting, sometimes 16 MB, sometimes more. This setting will affect the file upload procedure only
    - "set_time_limit" (e.g. 30 seconds) :: if the execution time of a script exceeds this limit for whatever reason, the server simply shuts it down without letting you (respectively the flash uploader) know it´s been shut down. This *might* be the reason why ADDT´s flash uploader hangs respectively returns that error message after some time, because it´s waiting for some response from the server which never comes.
    - "memory_limit" (e.g. 8 MB) :: this directive is a sort of "allocated server RAM" for your account, and it´s in particular the image resizing process which will grab more or less memory resources -- the higher the the resizing factor is, the more RAM is spent, and the more images are getting resized in one swoop, the worser it gets.
    However, all these PHP directives can be changed, and your host might even be so courteous to increase the currently defined values of those abovementioned directives for you -- and that´s what I´m suggesting at this point.
    Cheers
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Why does Illustrator on Windows 7, 64bit, take 30seconds+ to save a simple image?

    This question is for Adobe Customer Service, thanks. 
    Why does Illustrator on Windows 7, 64bit, take 30seconds+ to save a simple image comprising of two rectangles only (screen shot below)?  I set up a document like this to test the speed, since I've been having trouble saving all documents - they hang, sometimes with the 'this program is not responding' message.   Switching to CC is not an option.
    If it helps, I can come down to the Adobe San Francisco office with my computer.  I've spent a long time trying to resolve this without success.
    Btw, Photoshop CS6 saves fine.
    Thanks again.

    knot,
    Customer Care is over there:
    I believe this is one for Customer Care (tick I Still Need Help and hope for an agent available for a chat),
    http://helpx.adobe.com/contact.html?product=illustrator&topic=downloading-installing-and-s etting-up
    Sometimes staff appear here.
    We are just the natives.
    Can you create artwork without delays?
    Is there a printer (driver) set up?
    Are you saving to own harddisk (recommended) or somewhere else?

  • Blurry images when zooming in Survey & Grid View

    When I am in Survey View and hit the Z key, some of  the previews are blurry.  The same thing happens in Grid View.  However, in Loupe View, the images are fine when I the 'Z' key.  Using Survey View would make things go faster when making my picks.  Any ideas why this happens?
    I tried rendering 1:1 but the returns a mesage that says renders are up to date and rendering was done.

    cppasm wrote:
    This is definitely a bug. I can see it too, and it's little bit annoying. LR 4.1, Win7 x64.
    To reproduce just select two images, render 1:1 previews to be shure they are present.
    Then press 'N' to switch to Survey mode, and now press 'Z' to zoom in active photo.
    It gets zoomed, but looks like LR zooms in standard (smaller) preview instead of using 1:1 preview - the result is blurry and a little pixelated, it definitely lacks resolution.
    But when in the Loupe view (switch view using 'E') and zooming all work just fine - the image is at full resolution and is sharp.
    And even if I switch from Survey to Loupe with zoomed in image - it still stays blurry.
    To get sharp image I need to zoom out and then zoom in again.
    So in short - it looks like 1:1 preview is used only when image is zoomed in from the Loupe view.
    At least others seem to experience the same thing so I know it's not just me.  I'd say it's more than a little bit annoying because it causes you to second guess yourself and you constantly have to switch to a view to see if the image is actually sharp or not.  It really slows down the workflow.

  • Simple image component question

    I have to fix a flash file someone else made, and I need to use an image component, which I'm not familiar with.
    I just need a simple image that scales up, and then moves across the screen. I've got my image component, and tweened it to scale and then move, and it looks fine when I scrub the timeline, but when I test as a swf it doesn't do anything, it just sits there.
    Am I missing something?

    If its working on while dragging the timeline during in authoring and not working while playing the complied swf can mostly mean that u have attached a top command somehwere in ur code which is stopping the timeline from moving forward on playing the swf.Check for unwanted stop commands.

  • Simple Image Gallery for iWeb

    Hi there,
    Hoping someone can help. I've been searching high and low for an incredibly simple image web gallery generator. It simply has to have a larger image to the left and 3/4 smaller thumbnails to the right which, when clicked on, will appear in the bigger window. That's it! I don't want any text on it at all - just on a white background. The intention is to then upload the individual galleries of my work and use iFrames within my iWeb created website to point towards the galleries.
    Please can anyone help and point me in the direction of a good bit of software that will allow me to do this. I have no HTML experience to speak of.
    Thanks
    Sam

    Sam ~ This +"HTML Picture Viewer"+ would be easiest to implement using iWeb '08's +HTML Snippet+ window:
    http://web.mac.com/catucker/InsideOutside/PictureViewer.html
    ...it has the larger image to the right, but I suppose someone here could tell you how to reverse that. And the image changes not on a click of a thumbnail, but on mouseover.

  • Creating a simple image application in Apex

    select
    "IMAGE_ID",
    <img src="#OWNER#.deliver_thumbnail?p_image_id='||IMAGE_ID||'"/> thumbnail,
    "FILENAME" from "ORDIMAGE_IMAGES"
    where
    instr(upper("FILENAME"),upper(nvl(:P1_REPORT_SEARCH,"FILENAME"))) >
    Its is showing an error
    showing only the coding part when i run the application instead of showing image....
    can you please help me rectify the error
    Edited by: 880021 on 17-Aug-2011 20:58

    Creating a simple image application in Apex
    Create a new application from scratch. Name it ORDImages_images.
    Add a Report and Form Page based on your ORDImage_images table. Ensure that you select a Classic Report (i.e. not Interactive, which is the default). As expected, two pages are created.
    Continue to create the application and then run it.
    After the login page, there will be spurious entries for image and thumbnail.
    This is expected because of the ORDImage columns in the images table.
    Edit Page 1 and open the Images Region
    The Source entry is
    select
    "IMAGE_ID",
    "IMAGE",
    "THUMBNAIL",
    "FILENAME"
    from "ORDIMAGE_IMAGES"
    where
    instr(upper("FILENAME"),upper(nvl(:P1_REPORT_SEARCH,"FILENAME"))) > 0
    In SQL Developer, create the deliver_images_thumb procedure
    CREATE OR REPLACE PROCEDURE deliver_thumbnail(p_image_id IN NUMBER) IS
    l_thumbnail ORDSYS.ORDImage;
    BEGIN
    -- Fetch the thumbnail from the database
    SELECT thumbnail
    INTO l_thumbnail
    FROM ORDImage_images
    WHERE image_id = p_image_id;
    -- Check update time if browser sent If-Modified-Since header
    IF ordplsgwyutil.cache_is_valid( l_thumbnail.getUpdateTime() )THEN
    owa_util.status_line( ordplsgwyutil.http_status_not_modified );
    RETURN;
    END IF;
    -- Set the MIME type and deliver the image to the browser.
    owa_util.mime_header( l_thumbnail.mimeType, FALSE );
    ordplsgwyutil.set_last_modified( l_thumbnail.getUpdateTime() );
    owa_util.http_header_close();
    IF owa_util.get_cgi_env( 'REQUEST_METHOD' ) <> 'HEAD' THEN
    wpg_docload.download_file( l_thumbnail.source.localData );
    END IF;
    END;
    Then
    GRANT EXECUTE ON deliver_thumbnail TO PUBLIC;
    Return to Apex and change the Source entry to
    select
    "IMAGE_ID",
    '<img src="#OWNER#.deliver_thumbnail?p_image_id='||IMAGE_ID||'"/>' thumbnail,
    "FILENAME" from "ORDIMAGE_IMAGES"
    where
    instr(upper("FILENAME"),upper(nvl(:P1_REPORT_SEARCH,"FILENAME"))) > 0
    Apply changes and run the application
    You can now search on substrings of filenames. Note that the image_ID is not shown. To rectify this, Edit Page 1 and open Report in Regions.
    Edit the image_id and under Column Link, change the Link Text to #IMAGE_ID#. Also change the Heading in the Column Attributes to Image ID.
    Apply the changes and re-run.
    Clicking on the image_id link takes you to Page 2 – the form for that image.
    Page 2 is sparse so reveal the image_id by Editing Page 2 and opening the P2_IMAGE_ID Page Item. Change Display as Hidden to Text Field. Apply changes and re-run.
    In Page Items, open and delete the P2_THUMBNAIL item.
    Open the P2_IMAGE item.
    Under Name, change the Display As entry to Display Image (from the select list).
    Under Settings, change the Based On entry to BLOB Column returned by SQL Statement
    Enter
    SELECT i.image.source.localdata
    FROM ORDimage_images i
    WHERE image_id = :P2_IMAGE_ID
    as the SQL Statement
    Apply changes and re-run the application
    Making an image clickable
    Edit Page 1 and open Report in Regions. Edit THUMBNAIL and under Column Link, insert
    <img src="#OWNER#.deliver_thumbnail?p_image_id=#IMAGE_ID#"/>
    as Link Text.
    Select Page 2 as the Target Page in this Application.
    Finally, set Item 1's name to P2_IMAGE_ID and its Value to #IMAGE_ID#
    Removing the Spreadsheet link
    Under Report Attributes, set Enable CSV Output to No

  • Question on Photoshop Image Size Zoom & Crop

    Hello Everyone...
    I was wondering if anyone could help me out on a few questions w/ Image Size Zoom & Crop
    I use to work at a studio that had their own small software for editing photos. It was setup so you take an image RAW and you could CROP by zooming. So I could take the image and SCROLL to ZOOM in and it cropped away the rest without actually pressing crop. Then you pick what sizes you want, 1 8x10, 2 5x7 and sheet of wallets and WALLLLLLA it prints them out on 3 sheets of paper.
    My questions are:
    Is there anyway to crop by zooming?
    Is there anyway to keep the original size after cropping?  Example most of my pics are 12M when I crop they go down to 2 or 3. Why? If I have a picture of 4 people and I want to crop to one persons face but keep the original image size why won't it do that without resizing??
    It says that to get the best print quality it should be viewed at resolution 300 instead of 72? is that true? and why?
    Is there a way to keep the quality at its best and then just select how many and what size I want to have print out? example of the 3 sizes listed above??
    I hope my questions make a little sense.
    Thanks for your help in advance

    I strongly recommend that you read through the following:
    http://kb.adobe.com/selfservice/viewContent.do?externalId=331327
    http://help.adobe.com/en_US/Photoshop/11.0/WSfd1234e1c4b69f30ea53e41001031ab64-7636a.html# WSfd1234e1c4b69f30ea53e41001031ab64-7632a
    I also suggest that you mention what version of Photoshop you have when posting.  Some functions change between versions.

  • Problem w/saving simple image as .png

    Hello:                                                                                                                            Level: Newbie'ish   OS: Win7 64bit   PS: CS6
    I have been making a simple image of a 300 by 100 rounded rectangle and then adding various layer styles. Basically I am makeing mobile headers which will be used for mobile websites.
    Today I was reviewing  a few that I have made and noticed that when I open them in their .png format and then create a selection around one (Ctrl + Click) that the lower right coner is not being selected as rounded but as a point and so when I copy and then paste it into a new document it has three rounded corners and one somewhat visible pointed corner.  ?? ??
    The file has a BG layer and two shape layers (or sometimes just one shape layer). I select the layers and then merge them together and turn off the BG layer beofore I save them for the web. I have also tried just saving the file as a .png w/out merging the layers but no matter how I go about saving the file(s) most of the time one corner is saved w/that annoying and imperfect sharp corner.
    Any ideas? Your time is greatly appreciated ~ Thanx a Bunch!!

    Hey c.pf...
    sorry for just getting back ~ the holiday season has me run'n Crazy.
    any way, i figured out my problem. i hadn't realized that i accidentally clicked the outer glow option and it was so faint that i couldn't see it all that well or actually ~ at all until i went back through the LS ...
    so, when i would save the image (mobile header) it was including or making room for the outer glow
    funny how something so simple can be overlooked.
    well, sorry for bothering ya over nothing ~ but i really appreciate your willingness to help me out
    hope all is well!! thanx again!

  • After downloading latest software update i phone 5 sreen images are zoomed in cant correct

    after downloading the latest software update on my i phone 5  the screen images appear zoomed in  i cant uses the phone

    Double-tap the screen with three fingers to reduce the magnification. Go to Settings > General > Accessibility > Zoom and turn this OFF.

  • How do i double click image to zoom it?

    try to double click image to zoom but failed??

    Is this an issue with a website? Please explain more clearly what you are trying to do.

  • Is it possible to set an image to zoom full screen when clicked?

    Hi Guys
    Quick question...
    Is it possible to set an image to zoom full screen when clicked?

    You can create a button that displays a larger image:
    http://blogs.adobe.com/indesigndocs/2010/12/hot-spot-button-workaround-for-indesign-dig-pu bs.html

Maybe you are looking for