| Reply | « Previous Thread | Next Thread » |
|
i want to know that how can i get the byte[] from the Image object its urgent.
Regards Muhammad Shouab |
|
public String serializarImagen(Image img){
int[] imgRgbData = new int[14700]; //Creamos un array de pixels del tamaño de la foto (es constante: 140*105) img.getRGB(imgRgbData, 0, 140, 0, 0, 140, 105); //Pasamos los pixels de la imagen al array byte[] misBytes = null; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); for (int i = 0; i < (14700); i++) { //Escribimos en un array de bytes dos.writeInt(imgRgbData[i]); //Escribo el entero como 4 bytes } dos.flush(); //Los elementos que pudieran quedar "en medio" los termino de pasar al array en memoria misBytes = baos.toByteArray(); }catch (Exception e) {/*e.printStackTrace();*/ System.out.println("linea 674");} return (misBytes); } |
|
its return type should be byte[] not String and whts the language for the comments i am unable to get it.whts 14700 y u take it constant any reason.
thx Regards Muhammad Shouab |
|
my guess: 14700 = 140 x 105 which is the expected size of the image. If you have a picture of different size, you should use different array size.
Hartti |
|
yup u r rite its the dimenssions.
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| image() to byte[] | tongtoi | Mobile Java Media (Graphics & Sounds) | 5 | 2008-08-12 12:58 |
| --- ???save image problem??? --- | ferenn | Mobile Java Media (Graphics & Sounds) | 6 | 2007-10-01 15:33 |
| HELP: Mutable Image to Immutable Image? | rj_cybersilver | Mobile Java Media (Graphics & Sounds) | 1 | 2005-03-26 10:58 |
| saving jpeg image on grid list | flicker82 | General Symbian C++ | 0 | 2005-01-21 05:22 |
| png image to byte[] | shine_jp | Mobile Java Media (Graphics & Sounds) | 6 | 2004-02-19 09:37 |