0

I have been rebuilding the ImageJ library so that it is compatible with android. I am stuck on one of the constructors in PixelGrabber. Bare in mind that I have rebuilt the ImageJ and the awt library so that it takes Bitmap.

My class ColorProcessor constructor

public ColorProcessor(Bitmap img) {
        width = img.getWidth();
        height = img.getHeight();
        pixels = new int[width * height];
        PixelGrabber pg = new PixelGrabber(img, 0, 0, width, height, pixels, 0, width);
        try {
            pg.grabPixels();
        } catch (InterruptedException e){};
        createColorModel();
        fgColor = 0xff000000; //black
        resetRoi();
    }

Creates an object from PixelGrabber class. Here is the constructor for that.

public PixelGrabber(Bitmap img, int x, int y, int w, int h, int[] pix,
            int off, int scansize) {
        this(img.getSource(), x, y, w, h, pix, off, scansize);
    }

There is a red line under getSource(). This code was designed for the JRE so this getSource is referring to java.awt.Image abstract class. Does anyone know what I can replace img.getSource with? Any help would be much appreciated.

  • Well, what does `getSource()` return? What is `PixelGrabber` expecting? – CommonsWare Aug 28 '14 at 16:33
  • I think you are at the point where you have to figure out how you are going to do the image processing on Android: Java, C/JNI, or Renderscript. You can extract out the Android Bitmap into a Java Buffer class but from there its up to you. – Morrison Chang Aug 28 '14 at 16:39
  • getSource is an empty abstract method from abstract class Image. public abstract class Image { public abstract I_ImageProducer getSource(); } – James W'almsley Aug 28 '14 at 17:08
  • I_ImageProducer is just an interface. Morrison I have never done that before could you point me at the right direction in how I extract Bitmap into a java Buffer? – James W'almsley Aug 28 '14 at 17:10

0 Answers0