View Single Post
Old 05-20-2008, 02:30 AM   #9
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

i just looked up my code, been a while and i am not sure if it worked correctly:

Code:
 /**
* Receive bytearray containing the pixel positions of a bitmap which are painted.
* @param bmp Bitmap to receive painted pixels
* @return Bytearray of numbers with positions of painted pixels */
 public byte[] getBytesFromBitmap(Bitmap bmp) { 
 try {
        int height=bmp.getHeight();
        int width=bmp.getWidth();
        int[] rgbdata = new int[width*height];
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(bos);
        Graphics g = new Graphics(bmp);
        bmp.getARGB(rgbdata,0,width,0,0,width,height);
        for (int i = 0; i < rgbdata.length ; i++) {
            if (rgbdata[i] != -1) {
                dos.writeInt(i);
                dos.flush();
                //l++; 
                }
             } 
         bos.flush();
         return bos.toByteArray(); 
       } catch (Exception ex) {
            Dialog.alert("getBytesFromBitmap: " + ex.toString()); return null; } 
}
__________________
java developer, Devinto, hamburg/germany
Offline   Reply With Quote