You Are Here:

Community: Developer Discussion Boards

#1 Old Howto convert to ushort_4444-files? - 2003-10-17, 00:28

Join Date: Jun 2003
Posts: 8
Quart02
Offline
Registered User
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
Reply With Quote

#2 Old 2003-10-17, 09:19

Join Date: Jul 2003
Posts: 1,094
Location: Finland, Tampere
doctordwarf
Offline
Super Contributor
You can use DirectGraphics.getPixels()

Alternatively you can prepare byte arrays on your PC and store them as JAR file resources
Reply With Quote

#3 Old JAR file resources - 2003-10-20, 21:10

Join Date: Jun 2003
Posts: 8
Quart02
Offline
Registered User
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
Reply With Quote

#4 Old 2003-10-21, 08:39

Join Date: Jul 2003
Posts: 1,094
Location: Finland, Tampere
doctordwarf
Offline
Super Contributor
This format is very close to 24-bit BMP.

I use custom-build tool to convert BMPs
Reply With Quote

#5 Old A trick - 2003-10-21, 10:04

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
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
Reply With Quote

#6 Old It works!!! - 2003-10-21, 13:21

Join Date: Jun 2003
Posts: 8
Quart02
Offline
Registered User
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
Reply With Quote

#7 Old 2003-10-21, 13:29

Join Date: Jul 2003
Posts: 1,094
Location: Finland, Tampere
doctordwarf
Offline
Super Contributor
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?
Reply With Quote

#8 Old 2003-10-21, 17:34

Join Date: Aug 2003
Posts: 134
dannyc4
Offline
Regular Contributor
But the RMS-solution was genious, since the Nokia UI API already supports getting shortarrays with DirectGraphics.getPixels()

Indeed!!! Thanks Shmoove!
Reply With Quote

#9 Old 2003-10-21, 18:37

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
No problem. Just keep the flattery coming in (I specially enjoyed the genius part) and you can probably get me to do anything! ;)
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

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: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X 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