java me - How can I convert an Image to byte array in J2ME? -
My requirement is this way I need to read a file from a mobile phone using a file connection, Create thumbnails and post to the server I am able to read the image using the FileConnection API, and I am also able to create thumbnails.
After creating thumbnails, I'm not able to get a method to convert that image into byte [] Is this possible?
Code for thumbnail conversions:
Create a Personal ImageTabal (Image Image) {int sourceWidth = image.getWidth (); Int sourceHeight = image.getHeight (); Int Thamb Wide = 128; Int thumb height = -1; If (Thumb HEIGHT == -1) Thighthought = Thumb Wide * SourceHight / SourceView; Image thumb = Image.createImage (thumbWidth, thumbHyight); Thumb.getGraphics (); Graphics G = thumb.getGraphics (); For (int y = 0; y & lt; thumbHeight; y ++) to {(int x = 0; x & lt; thumbWidth; x ++) {g.setclip (x, y, 1, 1) ; Int dx = x * sourceWidth / thumbWidth; Int dy = y * sourceHeight / thumbHeight; G.drawImage (Image, X - DX, Y - D); }} Image irreversible roof = image. Creation image (thumbs); Thumb back; }
MIDP2.0 as a gap Aarjipi pixel data You can get:
int w = the image.getWidth (); Int h = theImage.getHeight (); Int [] argb = new int [w * h]; TheImage.getRGB (argb, 0, w, 0, 0, w, h);
int array can then be used as a parameter or desktop in Java, it can be used as follows:
BufferedImage Img = new BufferedImage (w, h, buffed image .ipep_indarab); Img.setRGB (0, 0, W, H, ints, 0, w);
Comments
Post a Comment