Accessing pixels of an image

is it possible to access the byte[] imageData of an javax.microedition.lcdui.Image Object? If not, what can i do to get the imageData of an image in PNG-Format?

Nope !
The only way is to get the images data from an HTTP connection as byte[] that you store in RMS for further Image objects creations.

Similar Messages

  • OSX: Updating pixel data for image

    Heya
    I have a buffer of pixel data that I need to update/change once every 25ms or so.  What's the best way of creating a UI element that I can update on the fly?  It looks like my old way of creating an NSBitmapImageRef and getting a pointer to the data via getBitmapDataPlanes was broken in the transition from 10.5-10.6 [1].  A workaround is to create a new NSBitmapImageRef every time I want to update and render a frame, but that creates a ton of object churn.  I figure there's got to be a better way to have byte-level access to a UI image of some kind.  Thoughts?
    Thanks
    [1] https://groups.google.com/forum/?fromgroups#!topic/cocoa-dev/f05K9ZaafMw

    Theoretically it may be doable assuming the tool used to modify B triggers proper events (not every tool does, unfortunately) AND your updates to layer A can be performed without disrupting user's work on B. What you'd need to do in this case is to implement an automation plugin based on Listener from the SDK samples that would monitor the events. Upon the event you'd need to determine the activate layer in your C++ code and if it's B then update A. The problematic part here would be whether you'd able to modify the non-current layer in a fashion that doesn't interrupt user's work on B (for example, you probably wouldn't want upon any change on B to change the current layer to A which would cause the focus to jump to A and then go back) and this would depend on the the type of changes you'd like to make there.
    Anyway, this would be the general direction I'd take here.
    HTH
    ivar

  • How can I get to read the pixels in an image?

    Please see details of my code below. What I am doing is trying to obtain the pixels for an image. there is an initial image of a certain size, which is then split into smaller portions.
    The problem I'm getting is that pixels can not be read past the middle of the original image. I hope I have explained this so it can be understood. I have included the class that I am working on
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package MandelbrotConstruction.compression;
    import java.awt.*;
    import java.awt.color.ColorSpace;
    import java.awt.geom.AffineTransform;
    import java.awt.image.*;
    import java.io.*;
    import java.util.ArrayList;
    import javax.imageio.ImageIO;
    import javax.swing.JPanel;
    * @author Charlene Hunter
    public class DisplayImg extends JPanel {
        private static BufferedImage image;
        private static ArrayList<Range> rangeLot;
        private static ArrayList<Domain> domainLot;
        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            int w = MainFrame.getJPanel1().getWidth();
            int h = MainFrame.getJPanel1().getHeight();
            Graphics2D g2 = (Graphics2D) g;
            File img = MainFrame.getImgFile();
            image = null;
            if (img != null) {
                try {
                    image = ImageIO.read(img);
                    //filter the image with a grayscale
                    ColorConvertOp grayOp = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
                    image = grayOp.filter(image, null);
                    //scale image to the size of the panel
                    AffineTransform at = new AffineTransform();
                    at.scale(256.0 / image.getWidth(), 256.0 / image.getHeight());
                    AffineTransformOp resizeOp = new AffineTransformOp(at, null);
                    image = resizeOp.filter(image, null);
                    ArrayList<Range> r = createRanges(image, 3);
                    ArrayList<Domain> d = createDomains(image);
                    int i = 0;
                    for (Domain dom : d) {
                        System.err.println("this is " + i);
                        System.out.println(dom.getPixels());
                        i++;
                    CompareClass comparer = new CompareClass(r, d);
                } catch (IOException e) {
                    System.err.println("IOException");
            g2.drawImage(image, null, 0, 0);
        public static ArrayList<Range> createRanges(BufferedImage bi, int divisions) {
            int w = bi.getWidth();
            int h = bi.getHeight();
            rangeLot = new ArrayList<Range>();
            int k = (int) Math.pow(2, divisions);
            for (int x = 0; x < w; x = x + (w / k)) {
                for (int y = 0; y < h; y = y + (h / k)) {
                    BufferedImage range = bi.getSubimage(x, y, w / k, h / k);
                    double[] pix = range.getRaster().getPixels(x, y, range.getWidth(), range.getHeight(), (double[]) null);
                    Range r = new Range(x, y, range, pix);
                    rangeLot.add(r);
            return rangeLot;
        public static ArrayList<Domain> createDomains(BufferedImage bi) {
            int w = bi.getWidth();
            int h = bi.getHeight();
            domainLot = new ArrayList<Domain>();
            int step = 4;
            for (int x = 0; x < w - step; x = x + step) {
                for (int y = 0; y < h - step; y = y + step) {
                    BufferedImage domain = bi.getSubimage(x, y, 2 * step, 2 * step);
                    double[] pix = domain.getRaster().getPixels(x, y, domain.getWidth(), domain.getHeight(), (double[]) null);
                    Domain d = new Domain(x, y, domain, pix);
                    domainLot.add(d);
            return domainLot;
    }If what I have included is not sufficient, please let me know. the problem is only arising when the pixels are being obtained for the subimage
    Thanks

    Hi, the error message I am getting is (i'm printing out the x,y values and width and height so that I can see what going on) the whole image is 512x512, and I am grabbing pixels for squares of 64x64, but when it gets to 256 it throws an exception. I don'd understand why
    (x: 0, y: 0)
    width: 64, height: 64
    done!
    (x: 0, y: 64)
    width: 64, height: 64
    done!
    (x: 0, y: 128)
    width: 64, height: 64
    done!
    (x: 0, y: 192)
    width: 64, height: 64
    done!
    (x: 0, y: 256)
    width: 64, height: 64
    Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
            at java.awt.image.ComponentSampleModel.getSampleDouble(ComponentSampleModel.java:807)
            at java.awt.image.SampleModel.getPixels(SampleModel.java:823)
            at java.awt.image.Raster.getPixels(Raster.java:1613)
            at MandelbrotConstruction.compression.DisplayImg.createRanges(DisplayImg.java:83)
            at MandelbrotConstruction.compression.DisplayImg.paintComponent(DisplayImg.java:51)
            at javax.swing.JComponent.paint(JComponent.java:1006)
            at javax.swing.JComponent.paintChildren(JComponent.java:843)
            at javax.swing.JComponent.paint(JComponent.java:1015)
            at javax.swing.JComponent.paintChildren(JComponent.java:843)
            at javax.swing.JComponent.paint(JComponent.java:1015)
            at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
            at javax.swing.JComponent.paintChildren(JComponent.java:843)
            at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4979)
            at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4925)
            at javax.swing.JComponent.paint(JComponent.java:996)
            at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
            at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
            at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
            at java.awt.Container.paint(Container.java:1709)
            at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
            at sun.awt.RepaintArea.paint(RepaintArea.java:224)
            at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
            at java.awt.Component.dispatchEventImpl(Component.java:4060)
            at java.awt.Container.dispatchEventImpl(Container.java:2024)
            at java.awt.Window.dispatchEventImpl(Window.java:1791)
            at java.awt.Component.dispatchEvent(Component.java:3819)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

  • How do you reduce the pixels of an image to fit within certain requirements

    I am trying to get the pixels of an image to fit certain requirements. When I try to edit the image in iPhoto by clicking custom constrain and then enter the pixel of dimensions I want, it will not adjust the image to them. Does anyone know how I can do this?

    Select the pic in the iPhoto Window and go
    File -> Export
    in the resulting dialogue you can resize:
    Uploaded with plasq's Skitch!
    Regards
    TD

  • Getting a pixel in an image

    How can i get the color of a pixel in an Image object, or an array of bytes or integers of the image.

    use getRGB(int x, int y) method of BufferedImage.
    first convert your image object to bufferedImage object. then use above method.
    if any problems contact
    [email protected] or [email protected]
    best of luck!

  • How can I increase the number of pixels in an image?

    How can I increase the number of pixels in an image?

    You can't.
    The number of pixels in an image is decided by the camera that shoots the image
    With an app like Photoshop you can interpolate - this will make a guess as to what a particular pixel may look like based on the ones around it. Results can vary wildly and Photoshop is expensive.
    Regards
    TD

  • Just updated to 6.0 and I'm noticing random white pixels on black images.

    Just updated to 6.0 and I'm noticing random white pixels on black images. It's not my monitor since this doesn't happen to any other browsers. It might also be a plugin.

    Clear Cookies & Cache
    * https://support.mozilla.com/en-US/kb/Template:clearCookiesCache
    Clear the Network Cache
    * https://support.mozilla.com/en-US/kb/How%20to%20clear%20the%20cache#w_clear-the-cache
    Troubleshooting extensions and themes
    * https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes
    Update All your Firefox Plugins
    * https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    * http://www.mozilla.com/en-US/plugincheck/
    Troubleshooting plugins
    * https://support.mozilla.com/en-US/kb/Troubleshooting%20plugins
    Check and tell if its working.

  • Please help me!--rendering makes the images or video blurry (very pixelated) deteriorates the image  Adobe Premier Elements 13  need help!  .jpg and mpeg images,  but I have never "rendered" before since I got APE 13 about 6 weeks ago.  I am desperate for

    Please help me!--rendering makes the images or video blurry (very pixelated) deteriorates the image  Adobe Premier Elements 13  need help!  .jpg and mpeg images,  but I have never "rendered" before since I got APE 13 about 6 weeks ago.  I am desperate for assistance!

    That's going to be a ridiculous waste of money and energy.
    First of all, the current ATI drivers don't support multiple GPUs, so at the moment even a single 4870X2 would be only a 'normal' 4870 (which is quite a speed beast already). GFX drivers evolve rapidly, so things might look different next month, but when it comes to Linux and hardware there's one Golden Rule: stay away from the newest stuff and wait for proper support to get coded.
    I also wonder what power supply could possibly cope with the differences between idle and full load; that's way beyond 400W. But then, I'm one of those "quiet&green" types where >100W idle is already a bit much.
    I kind of understand that you want to get it done and not worry about hardware for the next 10 years or so, but that's simply not how the hardware world works and never did. At least not for the average consumer.

  • Get the color of a pixel in an image

    how can i do to get the color of a pixel in an image ???
    Can anyone help me ?

    Hi,
    first of all you need to get the library to transfer your image to java.awt.image.BufferedImage object.
    I know many such libraries. Its depends of what kind of image you have: jpeg, gif, png or other.
    And when you get the BufferedImage of you picture using library, then you can get the color of any pixel in image using int BufferedImage.getRGB(int x, int y) as integer value.
    Victor Letunovsky

  • Color overlay on opaque pixels of transparant image

    Hi everyone!
    I'm having a little problem here... I have loaded a gif image (a bufferedimage) in my program and I would like to have a color overlay on it. However, the overlay should only reside on the opaque pixels and not on the transparant parts of the image.
    I have looked for about an hour on this board to find the solution to my problem, but I haven't found anything useful. I did find the following, but it's not for a bufferedimage :(
    int pixels[][] = grabPixels(sprite);       
         // 2) Place the opaque pixels in a polygon
         Polygon poly = new Polygon();
         for (int y = 0; y < spriteH; y++) // y coordinate
              for (int x = 0; x < spriteW; x++) // x coordinate
                   if (pixels[y][x] != TRANSPARENT) {
                        poly.addPoint(x,y);
         }This code creates a polygon with the opaque pixels of the image I think. Too bad it's not for a bufferedimage!
    Thanks ahead!
    Jens

    Thanks, Randy. That's ingenious, but it doesn't seem to work very well, since the finished image looks like Frankenstein's monster, with half the guy's face looking one way and the other half another way. But ingenious.
    I don't mind using the limit effect if that is the best way to deal with my little problem. Just trying to get a consensus on what to do, after I put a contract out on this shooter.
    Thanks.
    Giraut

  • Getting a pixel between thumbnail images

    Hi Folks
    I am using a CellRenderer to display thumbnail images,and I want to
    keep a distance of 1 pixel between the images.
    What can I do to get this?
    Attached is my renderer
    public FTRDPictureChooserDateAndTimeCellRenderer(){
         thumbnailImage    = new JLabel();
         imageText         = new JLabel();
         dateAndTimeLabel  = new JLabel();
         gbl = new GridBagLayout();
         setLayout(gbl);
         gbc = new GridBagConstraints();
         gbc.gridx      = 0;       // x represents cols
         gbc.gridy      = 0;       // y represents rows
         gbc.gridwidth  = 1;               // reset to the default
         gbc.gridheight = 2;       // span 2 rows to display image.
         gbc.weighty    = 1.0;
         gbc.weightx    = 1.0;
         add(thumbnailImage,gbc);
         /* Image Name */
         gbc.gridwidth  = GridBagConstraints.REMAINDER; //end row
         gbc.gridheight = 1;     
         gbc.gridx      = 1;          
         gbc.gridy      = 0;
            add(imageText,gbc);                                                      
         setOpaque(true);
                                                                          

    Well, let's see... now if I look at the API docs for
    GridBagConstraints, I see it has fields: ipadx and
    ipady ... I wonder what they do?They pad inside the component so won't actually help. However, the insets field will allow you to define the number of pixels to pad outside the component. So you can either do gbc.insets = new Insets(0,0,0,1) from the first component or gbc.insets = new Insets(0,1,0,0) for the second one. Either will add a single pixel between them.
    Ian

  • Finding the Brightest Pixel in an Image

    How do i select the brightest pixel in an image?

    Set a threshold adjustment layer over your image. Drag the slider to the right until you see the last remaining white specks. These are where your brightest pixels are.

  • Browser can resolve, access, and display JPEG image, but ImageIcon can't.

    I've got this weird problem that only happens with images accessed through a customer's VPN:
    Microsloth Internet Imploder can resolve, access, and display a JPG image from a VPN URL, in the general form:
    http://intranet/part?FOOBAR.JPG which the browser apparently transmogrifies into
    http://mogrify.foo.com/images/scripts/cgi/detail.cgi?FOOBAR.JPG(as Jack Webb often said, the names have been changed to protect the innocent)
    Firefox can also resove, access, and display the image.
    But an ImageIcon, when fed either URL, quietly fails to get anything, No errors, no exceptions, but no image, either.
    The application, if it detects the failure of ImageIcon to come up with the image, somehow (not my code) defers to "Windoze Image and Fax Viewer," which locks up trying to resolve, access, and display the image.
    What could possibly be going on here?

    I'd love to have the luxury of saying, "You lost me at Windoze." Then again, to paraphrase a running gag from Airplane!, it looks like I picked the wrong week to quit hemlock.
    As my final message on my other thread on this topic indicates, the problem is that even though the URL ends in JPG, the server isn't really serving up a JPEG, but rather, an HTML page containing the JPEG.
    Knowing this, a solution (of sorts) presented itself: if the URL doesn't produce a displayable ImageIcon, try constructing a JEditorPane on the URL. The results aren't exactly pretty, and you do have to try the ImageIcon first, but it does work.
    JHHL

  • How do you tell the color value of a pixel in an image data

    Hi,
    Given a BufferedImage of type, say BufferedImage.TYPE_4BYTE_ABGR, how do you tell the color value of a pixel in the image?
    Specifically, in the following code:
    Raster imgData = image.getData();
    int x = imgData.getMinX();
    int y = imgData.getMinY();
    int width = imgData.getWidth();
    int height = imgData.getHeight();
    I want to search the raster looking for a specific color, e.g., Color.WHITE.
    According to the API, "getSample()" may be used for this purpose. But, how do you know which color band a band index parameter in getSample() refers to? Does band index of 0 always refer to the RED band? Does band index of 1 refer to the GREEN band? etc.
    I'd greatly appreciate any help you may be able to provide.
    Thanks,
    --HS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    In the print dialog underneath the settings for number of copies and print range you should see a dropdown menu probably called Layout. If you don't see that look for a button labeled Details and click it.
    Under the Layout menu you should find an option labeled Printer where you will find Printer specific options. Look for something there. You might also find an option called Color which may have options you are looking for.
    If this doesn't help, go to the printer manufacturer's website and look for answers there.

  • Looking for the brighter red pixel of an image

    Hi, I need to find the brighter red pixel of an image. I tried this code, but the value of each pixel seemed to be the same (zero).
    public static void findBrighterRedPoint(Image i, ImageObserver o){
         int redMax = 0; //0 to 255
         int xMax = 0;
         int yMax = 0;
         PixelGrabber pg = new PixelGrabber(i,0,0,i.getWidth(o),i.getHeight(o),true);
         ColorModel cm = pg.getColorModel();
         for(int a=0;a<pg.getHeight();a++){
              for(int c=0;c<pg.getWidth();c++){
                   if(cm.getRed(((a-1)*pg.getWidth()+c)) > redMax){
                        redMax = cm.getRed(((a-1)*pg.getWidth()+c));
                        xMax=c;
                        yMax=a;
                   if(f==(pg.getHeight()-1) && c==(pg.getWidth()-1)){
                   System.out.println("Red bound max value: "+cm.getRed(((a-1)*pg.getWidth()+c))+" Arrow: "+a+" Collumn: "+c);
    }//method endThanks for some help...
    Edited by: juanma268 on Jul 25, 2008 5:45 PM

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class LookingForRed extends MouseMotionAdapter {
        JLabel red, green, blue;
        BufferedImage image;
        public void mouseMoved(MouseEvent e) {
            Point p = e.getPoint();
            int rgb = image.getRGB(p.x, p.y);
            red.setText(String.valueOf(  (rgb >> 16)&0xff));
            green.setText(String.valueOf((rgb >>  8)&0xff));
            blue.setText(String.valueOf( (rgb >>  0)&0xff));
        public static void findBrighterRedPoint(Image i, ImageObserver o){
            int redMax = 0; //0 to 255
            int xMax = 0;
            int yMax = 0;
            int w = i.getWidth(o);
            int h = i.getHeight(o);
            int[] pixels = new int[w*h];
            PixelGrabber pg = new PixelGrabber(i,0,0,w,h,pixels,0,w);
            try {
                pg.grabPixels();
            } catch(InterruptedException e) {
                System.out.println("interrupt");
            ColorModel cm = pg.getColorModel();
            for(int a=0;a<pg.getHeight();a++){
                for(int c=0;c<pg.getWidth();c++){
                    int index = a*pg.getWidth()+c;
                    int pixel = pixels[index];
                    if(cm.getRed(pixel) > redMax){
                        redMax = cm.getRed(pixel);
                        xMax=c;
                        yMax=a;
                    if(a==(pg.getHeight()-1) && c==(pg.getWidth()-1)){
                        System.out.println("Red bound max value: "+redMax+
                                   " Arrow: "+yMax+" Collumn: "+xMax);
        private void showGUI(BufferedImage image) {
            this.image = image;
            ImageIcon icon = new ImageIcon(image);
            JLabel label = new JLabel(icon, JLabel.CENTER);
            label.addMouseMotionListener(this);
            JPanel panel = new JPanel(new GridBagLayout());
            panel.add(label, new GridBagConstraints());
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(panel);
            f.add(getLabelPanel(), "Last");
            f.setSize(300,300);
            f.setLocation(200,200);
            f.setVisible(true);
            findBrighterRedPoint(image, label);
        private JPanel getLabelPanel() {
            red = new JLabel();
            green = new JLabel();
            blue = new JLabel();
            Dimension d = new Dimension(45, 25);
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(2,2,2,2);
            gbc.weightx = 1.0;
            addComponents("r =", red,   panel, gbc, d);
            addComponents("g =", green, panel, gbc, d);
            addComponents("b =", blue,  panel, gbc, d);
            return panel;
        private void addComponents(String s, JLabel jl, Container c,
                                   GridBagConstraints gbc, Dimension d) {
            gbc.anchor = GridBagConstraints.EAST;
            c.add(new JLabel(s), gbc);
            jl.setPreferredSize(d);
            gbc.anchor = GridBagConstraints.WEST;
            c.add(jl, gbc);
        public static void main(String[] args) {
            LookingForRed test = new LookingForRed();
            BufferedImage image = test.makeImage();
            test.showGUI(image);
        private BufferedImage makeImage() {
            int w = 200, h = 200;
            int type = BufferedImage.TYPE_INT_RGB;
            BufferedImage image = new BufferedImage(w, h, type);
            int[] data = new int[w*h];
            int x = 3*w/4;
            int y = 3*h/4;
            System.out.println("Max red value should appear at " +
                               "x = " + x + "  y = " + y);
            int a = 255;
            for(int j = 0; j < h; j++) {
                int b = j*255/(h-1);
                for(int k = 0; k < w; k++) {
                    int r = (j == y && k == x) ? 255 : 127;
                    int g = k*255/(w-1);
                    data[j*w + k] = ((a & 0xff) << 24) |
                                    ((r & 0xff) << 16) |
                                    ((g & 0xff) <<  8) |
                                    ((b & 0xff) <<  0);
            image.setRGB(0,0,w,h,data,0,w);
            return image;
    }

Maybe you are looking for

  • Sharepoint 2013 RS - Adding a New "Data Source" or "Report Builder" in a Library

    I've installed SQL Server Reporting Services SharePoint Integration Mode. I also enabled SQL Reporting in the Library setting. But, When I click to open a new "Data Source" or "Report Builder" an error occurs: 'New Document' requires a Microsoft Shar

  • Using extract and existnodes in a SQL query

    I have created a table having one column of datatype xmltype in oracle 9i and inserted 2 rows. When I try to execute the select query having extract and existsnode it is giving me ORA-00904: invalid column name. CREATE TABLE xml_tab ( xmlval sys.xmlt

  • Partition based on join in data warehouse env.

    Hi, I am working on DW environment and am quite new to it. The scenario is like there are 2 fact tables and one dimension table. Now I need to partition both the fact tables based on the dates in Dim table. My problem is there is no date mentioned in

  • Another spry menu problem with ie

    I dont know, but i have tried everything to getie to render the spry menu for my site : http://www.jtltours.com/proofing/, but no luch to date. As you may have seen , it works perfectly with firefox and chrome, but no luch for ie. It does'nt even see

  • Af:Button useWindow issue

    Hi what is the problem with <af:Button> useWindow property? i have a search page and want to open an Edit page in a pop up window. So i use the following code for my command button: <af:commandButton text="Edit" id="cb2" action="dialog:Edit" useWindo