Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Tolls

Thread: Scanning Image Pixel by Pixel

  1. #1
    the_transltr is offline Member
    Join Date
    May 2008
    Posts
    1
    Rep Power
    0

    Default Scanning Image Pixel by Pixel

    I just want to know some idea on how to scan every pixel from an image file and put it into an array.

  2. #2
    roots's Avatar
    roots is offline Moderator
    Join Date
    Jan 2008
    Location
    Dallas
    Posts
    293
    Rep Power
    7

    Default

    dont worry newbie, we got you covered.

  3. #3
    M77's Avatar
    M77
    M77 is offline Member
    Join Date
    May 2008
    Location
    LV
    Posts
    43
    Rep Power
    0

    Default

    import java.awt.image.*;
    import java.awt.*;
    import java.applet.*;

    public class Sprite {
    private String name;

    public int[] b;
    public int w;
    public int h;

    public Sprite(Applet a, String filename, int width, int height) {
    try {
    name=filename.substring(0, filename.indexOf('.'));
    w=width;
    h=height;
    Image img=a.getImage(a.getDocumentBase(), filename);
    b=new int[h*w];
    PixelGrabber pg= new PixelGrabber(img, 0, 0, w, h, b, 0, w);
    pg.grabPixels();
    if (pg.status()==192) {
    throw new RuntimeException("error loading "+filename +" sprite");
    }
    //now b[0] is the leftest pixel of the top
    // b[w-1] is the rightest pixel of the top
    } catch(Exception e) {
    e.printStackTrace();
    }
    }
    }

  4. #4
    gogoc is offline Member
    Join Date
    May 2008
    Posts
    21
    Rep Power
    0

    Default

    depends upon the format of the image
    bitmap stores 3 variables for each pixel
    and there must be some api for doing image processing
    google for that
    get new coding problems at CODERWORDS

  5. #5
    Join Date
    Aug 2012
    Posts
    2
    Rep Power
    0

    Default Re: Scanning Image Pixel by Pixel

    i executed but Exception in thred "main" java .lang .No such method error

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,854
    Rep Power
    19

    Default Re: Scanning Image Pixel by Pixel

    Please don't resurrect old threads.
    Start your own and reference this one if you think it's relevant.

    I'm locking this.
    DarrylBurke likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Image Verification
    By peiceonly in forum Java Servlet
    Replies: 2
    Last Post: 04-04-2009, 07:38 AM
  2. image removing
    By Triss in forum New To Java
    Replies: 3
    Last Post: 01-20-2008, 08:27 PM
  3. Replies: 0
    Last Post: 01-08-2008, 05:29 PM
  4. how to set an image size
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 08:27 PM
  5. Replies: 1
    Last Post: 07-17-2007, 04:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •