You Are Here:

Community: Developer Discussion Boards

#1 Old how to get byte[] from image - 2006-07-07, 08:33

Join Date: Jul 2006
Posts: 33
mshouab
Offline
Registered User
i want to know that how can i get the byte[] from the Image object its urgent.
Regards Muhammad Shouab
Reply With Quote

#2 Old Re: how to get byte[] from image - 2006-07-07, 11:49

Join Date: Sep 2005
Posts: 119
Pepper_91
Offline
Regular Contributor
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);
}
Reply With Quote

#3 Old Smile Re: how to get byte[] from image - 2006-07-07, 13:10

Join Date: Jul 2006
Posts: 33
mshouab
Offline
Registered User
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
Reply With Quote

#4 Old Re: how to get byte[] from image - 2006-07-07, 23:12

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
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
Reply With Quote

#5 Old Re: how to get byte[] from image - 2006-07-11, 12:14

Join Date: Jul 2006
Posts: 33
mshouab
Offline
Registered User
yup u r rite its the dimenssions.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ