Hi,
If u want to store that in RMS then just get the integer array of the image using getRGB() method and the you can store it to the RMS using the streams.
boolean addImageToRecordStore(Image img, int width, int height,
String rsName, String imgName) {
if (img == null || width < 0 || height < 0 || rsName == null || rsName.length == 0 || imgName == null) {
throw new IllegalArgumentException("Check arguments");
}
if (width > img.getWidth()) {
width = imgWidth;
}
if (height > img.getHeight()) {
height = imgHeight;
}
int[] imgRgbData = new int[width * height];
try {
img.getRgb(imgRgbData, 0, width, 0, 0, w, h);
} catch (Exception e) {
// Problem getting image RGB data
return false;
}
try {
// Write image data to output stream (in order to get the record bytes in needed form)
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputImpl(dos);
dos.writeString(imgName);
for (int i = 0; i < imgRgbData.length; i++) {
dos.writeInteger(imgRgbData);
}
// Open record store, create if it doesn't exist
RecordStore rs = RecordStore.openRecordStore(name, true);
rs.addRecord(baos.toByteArray(), 0, baos.toByteArray().length); // Add record
rs.closeRecordStore();
} catch (RecordStoreNotFoundException rsnfe) {
// Record storage not found
return false;
} catch (RecordStoreException rse) {
// Other record storage problem
return false;
} catch (IOException ioe) {
// Problem writing data
return false;
}
return true; // We've successfuly done
}
I hope this code will help you