You Are Here:

Community: Developer Discussion Boards

#1 Old Post Save image in record store - 2008-03-06, 15:18

Join Date: Sep 2007
Posts: 28
nim_esh
Offline
Registered User
hello guys is there anyway to store an image in the recordstore... i wrote a program to take pictures using phone camera... i want to store it in memory so that i can retrieve it in future.. but as record store allows only data in byte format i want to know how i can convert image to bytes so that i can store it in recordstore...
Reply With Quote

#2 Old Re: Save image in record store - 2008-03-07, 12:58

Join Date: Sep 2007
Posts: 46
Location: Mumbai, India
Send a message via Skype™ to sanket2612
sanket2612's Avatar
sanket2612
Offline
Registered User
There u go--->

public boolean cacheImages(String ImageName,Image img)
{
int width = img.getWidth();
int height = img.getHeight();
byte[] outputRecord;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
DataOutputStream outputDataStream =new DataOutputStream(outputStream);
int[] imgRgbData = new int[img.getWidth() * img.getHeight()];

try {

img.getRGB(imgRgbData, 0, width, 0, 0, width, height);

} catch (Exception e) {
// Problem getting image RGB data
}
try {
// Write image data to output stream (in order to get
// the record bytes in needed form)
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF(ImageName);

for (int i = 0; i < imgRgbData.length; i++) {
dos.writeInt(imgRgbData[i]);
}

// Open record store, create if it doesn't exist
rms.addRecord(baos.toByteArray(), 0,baos.toByteArray().length); // Add record


} catch (RecordStoreException rse) {
// Other record storage problem
return false;
} catch (IOException ioe) {
// Problem writing data
return false;
}

return true;
}


Write the image in a byte array format. Also store the image name, and the form factor(width, height) as they will be usefull while reading the images from the rms.

Hope this helps
Reply With Quote

#3 Old Re: Save image in record store - 2008-03-10, 00:09

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hii Nimesh,
it is not wise to store images in record store because of the size limit.Just store these images in the phones and just store the URL of these images in the record store...I think this is very better when compared to the other one.
Thanks
Soku
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
How to use Browser Control to download an image , and then save to phone? caepek General Browsing 6 2009-11-10 09:31
store image in recordstore cars2004 Mobile Java Media (Graphics & Sounds) 9 2008-12-13 06:20
Display, modify and save image mazi888 Symbian Media (Graphics & Sounds) 1 2006-03-13 21:14
Record Store vs JDBC. How to store data? 180ºrevolution Mobile Java General 0 2004-09-17 16:24
3650 & Record Store basarim Mobile Java General 4 2003-12-10 23:20

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