You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Nishant <ni...@yahoo.com> on 2003/03/11 12:30:40 UTC

how to extract palette information

hi all,
I need to read a .png file and read the palette value as an
integer. 
I dont have any idea what is a palette.
could anyone provide help, about how to extract the same.

Thanks for any help.

Regards,
Nishant




________________________________________________________________________
Missed your favourite TV serial last night? Try the new, Yahoo! TV.
       visit http://in.tv.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: how to extract palette information

Posted by Loïc Minier <lo...@via.ecp.fr>.
Nishant <ni...@yahoo.com> - Tue, Mar 11, 2003:

> I was wondering if JAI can help me?

   dunnno :(

> Is there anything like palette defined for an entire png
> image type? because the palette sounds like for a pixel for
> me!

   ?


> one person told me that he extracts the palette information
> for gif using this code... will this work also for png
> format.

   Ouch, this is brute binary file reading, I strongly suggest you use a
 lib that does the job for you!

   Look at libpng's api and examples at
 <http://www.libpng.org/pub/png/libpng-manual.html>.


    Regards,

-- 
Loïc Minier <lo...@via.ecp.fr>

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: how to extract palette information

Posted by Nishant <ni...@yahoo.com>.
thanks a lot for the help lool. 

I was wondering if JAI can help me?

Is there anything like palette defined for an entire png
image type? because the palette sounds like for a pixel for
me!

one person told me that he extracts the palette information
for gif using this code... will this work also for png
format.

------ source
    // &#24133; &#12398;&#35501;&#36796;
    byte len1 = dis.readByte();
    byte len2 = dis.readByte();
    //
&#12522;&#12488;&#12523;&#12456;&#12531;&#12487;&#12451;&#12450;&#12531;
    width = (len2 & 0xff) * 256 + len1 & 0xff;
    // &#39640;&#12373; &#12398;&#35501;&#36796;
    byte hei1 = dis.readByte();
    byte hei2 = dis.readByte();
    //
&#12522;&#12488;&#12523;&#12456;&#12531;&#12487;&#12451;&#12450;&#12531;
    height = (hei2 & 0xff) * 256 + hei1 & 0xff;
    // Packet Fields &#12398;&#35501;&#36796;
    byte packetFields = dis.readByte();
    // Global Color Table Flag &#12398;&#35501;&#36796;
    globalColorTableFlag = ((packetFields & 128) == 128);
    // Color Resolution &#12398;&#35501;&#36796;
    int colorResolution = (packetFields & (16 + 32 + 64))
>> 4;
    // Size of Global Color Table &#12398;&#35501;&#36796;
    sizeOfGlobalColorTable = (packetFields & (1 + 2 + 4));
    // palette &#12398;&#35373;&#23450;
    palette = (1 << (sizeOfGlobalColorTable + 1));
-------------------------------------

Thanks and Regards,
nishant


 --- Loïc Minier <lo...@via.ecp.fr> wrote: > Nishant
<ni...@yahoo.com> - Tue, Mar 11, 2003:
> 
> > I need to read a .png file and read the palette value
> as an
> > integer. 
> > I dont have any idea what is a palette.
> 
>    I don't know if you're attached to Java, but libpng
> might help you
>  more than batik will in this case. There are functions
> to retrieve the
>  palette. The palette is an array of color description,
> for example
>  color #0 is blue 0,0,250 etc.
> 
> 
> -- 
> Loïc Minier <lo...@via.ecp.fr>
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> batik-users-help@xml.apache.org
>  

________________________________________________________________________
Missed your favourite TV serial last night? Try the new, Yahoo! TV.
       visit http://in.tv.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: how to extract palette information

Posted by Loïc Minier <lo...@via.ecp.fr>.
Nishant <ni...@yahoo.com> - Tue, Mar 11, 2003:

> I need to read a .png file and read the palette value as an
> integer. 
> I dont have any idea what is a palette.

   I don't know if you're attached to Java, but libpng might help you
 more than batik will in this case. There are functions to retrieve the
 palette. The palette is an array of color description, for example
 color #0 is blue 0,0,250 etc.


-- 
Loïc Minier <lo...@via.ecp.fr>

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org