Re: texture modification

New Message Reply Date view Thread view Subject view Author view

From: Boris Mansencal (boris.mansencal++at++inria.fr)
Date: 02/28/2002 02:27:48


Marcin Romaszewicz wrote:

> On Wed, 27 Feb 2002, Boris Mansencal wrote:
> > I have a texture that I want to modify.
> > I load an rgb file (not compressed). I do a pfTexture->getImage()
> > and I want to access the RGBA values of each pixel.
> >
>
>
> You should not be setting the external format. The loadFile function does
> this. You should call getFormat to query the current external format and
> then use that for your computations. I think that if you are not packing
> data, each components will be encoded as a ushort. You also have to make
> accomodations for the presence of an alpha channel.

If I do not set the texture external format, it is PFTEX_PACK_8 by default.

How do I access to the RGBA values of a pixel then ?

It seems that all the formats are for packed data, except
PFTEX_UNSIGNED_SHORT_5_5_5_1.
Is that right ?

I have also tried to do a setFromat before loadFile. The format is correctly
set (I can see it with getFormat),
but I can still not get a correct result with the following code :

tex = new pfTexture;
tex->setFormat(PFTEX_EXTERNAL_FORMAT, PFTEX_UNSIGNED_SHORT_5_5_5_1);
tex->loadFile("test.rgb");

tex->getImage(&bitmap, &comp, &ns, &nt, &nr);
for(i=0;i<ns*nt*nr; i++)
{
  printf("Col = %d,%d,%d\n", (bitmap[i] & 0xF800) >> 11,
                                         (bitmap[i] & 0x07C0) >> 6,
                                         (bitmap[i] & 0x003E) >> 1);
}

Do you see what's wrong with the previous code ?

Boris.


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Feb 28 2002 - 02:27:59 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.