You Are Here:

Community: Developer Discussion Boards

#1 Old How to get RGB values from PNG Data byte[] - 2003-10-17, 15:37

Join Date: Oct 2003
Posts: 3
Location: Switzerland
allypone
Offline
Registered User
hi...

Is there a way to get the rgb values from the following byte[]?

byte[] pngImage = videoControl.getSnapshot("encoding=png&width=240&height=180");

I know, it's possible with MIDP 2.0 or the Nokia UI API. But is there a way to do this with the MIDP 1.0 and the MMAPI?

Thanks for your help!

(I'm using the Nokia 3650)
Reply With Quote

#2 Old 2003-10-19, 18:37

Join Date: Aug 2003
Posts: 134
dannyc4
Offline
Regular Contributor
* DirectGraphics.drawImage( pngImage );
* short[] argbValues = new short[size];
* DirectGraphics.getBytes( argbValues, blah... blah, DirectGraphics.TYPE_USHORT_4444_ARGB);

Extract with:

short sample = argbValues[index];
int alpha = (sample>>12);
int red = ((sample>>8)&0x000F);
int green = ((sample>>4)&0x000F);
int blue = (sample&0x000F);
Reply With Quote

#3 Old 2003-10-19, 18:55

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
That's the Nokia UI way.
MIDP 1.0 offers no method for this.

shmoove
Reply With Quote

#4 Old 2003-10-19, 19:02

Join Date: Aug 2003
Posts: 134
dannyc4
Offline
Regular Contributor
Appearatly I didn't read the question well enough. You are right (ofcourse:).

gr,

Danny
Reply With Quote

#5 Old 2003-10-20, 12:42

Join Date: Mar 2003
Posts: 15
Location: Finland
sampoy
Offline
Registered User
Well, this isn't a solution to what you asked. Actually this is not a solution at all :)

I was wondering if the snapshot taken in BMP-format is uncompressed. If so, you could easily get the RGB-values from it. ?
Reply With Quote

#6 Old 2003-10-20, 13:38

Join Date: Oct 2003
Posts: 3
Location: Switzerland
allypone
Offline
Registered User
Yes... I think snapshot taken in BMP-format is uncompressed. But for getting the RGB-values, I need the exactly header-data length from this bmp format.
Reply With Quote

#7 Old 2003-10-20, 13:57

Join Date: Aug 2003
Posts: 134
dannyc4
Offline
Regular Contributor
Then you have to look in to the PNG specs. You must implement the Z-lib functionality yourself.

BTW is that video capturing also a pure MIDP1.0 solution? Or is it Nokia specific?

gr,

Danny
Reply With Quote

#8 Old 2003-10-20, 14:22

Join Date: Oct 2003
Posts: 3
Location: Switzerland
allypone
Offline
Registered User
should be a pure MIDP 1.0 solution....
Reply With Quote

#9 Old 2003-10-21, 00:36

Join Date: Aug 2003
Posts: 134
dannyc4
Offline
Regular Contributor
Would it be possible to implement z-lib? may also be usefull for creating (really) mutable MIDP1.0 Images... Advantage is indeed that it doesn't need to implement the compression algorithms.

PNG header stuff seams to be quite easy...
Last edited by dannyc4 : 2003-10-21 at 00:40.
Reply With Quote

#10 Old Zlib format - 2003-10-21, 16:56

Join Date: Mar 2003
Posts: 30
wesbiggs
Offline
Registered User
Yes, it's technically possible to generate a non-compressed PNG. I wrote a function that generates a transparent PNG with x/y size specified by parameters.

The biggest problem with generating viewable PNGs is that you need to calculate the checksum, so you at least need to include the Adler32 CRC algorithm.

Keep in mind that this method is going to be very memory-intensive, though.

Wes
Reply With Quote

#11 Old Building a PNG - 2003-12-12, 12:11

Join Date: Dec 2003
Posts: 3
marcbelmont
Offline
Registered User
Hi,

I'm trying to build a png out of a bmp. I need a fast and small zlib compression code (with compression 0). I already have all the other stuffs (crc32, header, filters...). Could someone help me / give me code :-) / tell me where to find a good documentation?

Marc Belmont
Reply With Quote

#12 Old Re: How to get RGB values from PNG Data byte[] - 2009-09-09, 18:37

Join Date: Sep 2008
Posts: 6
amri_cse
Offline
Registered User
Hi allypone,

You told its possible in MIDP2.0 to get rgb values from byte[] array.
Can you please tell me how to do that?

Thanks,
Amritendu
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