| Reply | « Previous Thread | Next Thread » |
|
Hi,
I was wondering if anyone could tell me how to convert an image into DirectGraphics.TYPE_USHORT_4444_ARGB? Are there any tools to do this? Thanks! Espen Berge |
|
You can use DirectGraphics.getPixels()
Alternatively you can prepare byte arrays on your PC and store them as JAR file resources |
|
Hi again,
I have tried out the DirectGraphics.getPixels(), but I'm really looking for a way to create byte array files to include them as JAR file resources. Are there any image tools or any file format to save as a byte file in the TYPE_USHORT_4444_ARGB-format? Cheers... Espen |
|
This format is very close to 24-bit BMP.
I use custom-build tool to convert BMPs |
|
I haven't tried this, but here goes:
Use the DirectGraphics.getPixels() method and store the resulting array in the RMS. Run this in an emulator, and the RMS data will be saved on your hard drive. Then you can get it from there. The Nokia emulators store there RMS data in the \bin\jam-apps\ sub directory of the SDKs. Alternatively if that doesn't work, instead of storing the array in the RMS you could send it through http to a server you set up to save the byte arrays. shmoove |
|
Thanks,
At first I was about to go for the 24-bit BMP solution, but I found out that I also needed a transparencyMask, since the files were only 24-bit. But the RMS-solution was genious, since the Nokia UI API already supports getting shortarrays with DirectGraphics.getPixels() I just wrote a simple void: public void saveImage4444intoRMS(Image img) { Image tempImg=DirectUtils.createImage(img.getWidth(),img.getHeight(),0x00ffffff); Graphic g=tempImg.getGraphics(); g.drawImage(img,0,0,0); DirectGraphics dg=DirectUtils.getDirectGraphics(g); short[] shortarray=new short[img.getWidth()*img.getHeight()]; dg.getPixels(shortarray,0,img.getWidth(),0,0,img.getWidth(),img.getHeight(),4444); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream outputStream = new DataOutputStream(baos); try { for (int i=0;i<shortarray.length;i++) outputStream.writeShort((int)shortarray[i]); } catch (IOException ioe) {} byte[] b = baos.toByteArray(); try { recordStore = RecordStore.openRecordStore("file", true); recordStore.addRecord(b, 0, b.length); } catch (RecordStoreException rse) {} } And it works perfectly :) Thanks! Espen |
|
Does the RMS file contain only your array (i.e. ready to use) or there is also some header info, that you need to strip out first?
|
|
But the RMS-solution was genious, since the Nokia UI API already supports getting shortarrays with DirectGraphics.getPixels()
Indeed!!! Thanks Shmoove! |
|
No problem. Just keep the flattery coming in (I specially enjoyed the genius part) and you can probably get me to do anything! ;)
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|