Daniel E. Small (desmall++at++isrc.sandia.gov)
Sun, 16 Mar 1997 15:15:10 -0800
Newbie questions continued.
I a bunch of texture data from video that I need to map. I would like
to conserver memory, so I want to take the 24 bit data and reduce it to
16, and scale the image down by 1/2, ending up with a 320x240 16bit
image. (I know they are not powers of 2 but I have some complex video
calibration issues that I have to deal with before attempting that piece
of optimization).
I convert each texel component to 5 bits and shift them in the following
manner:
r,g&b are ushort arrays.
unsigned short tr;
unsigned short tg;
unsigned short tb;
unsigned short dest;
tr = ((r[i]&0x00f8)>>3);
tg = ((g[i]&0x00f8)<<2);
tb = ((b[i]&0x00f8)<<7);
dest = tr | tg | tb;
I am 'assuming' that the bit ordering is (from lowest to highest) 5 bits
red, 5 bits green, 5 bits blue, and 1 bit alpha. Please enlighten me if
I am in error.
I know the data is good because I am able to use this method to create a
texture of 32 bits in the same method; by shifting green by 8 and blue
by 24 and or'ing the 3 components. I am scaling down hthe 24 bit image
and it looks fine.
Using the above method, I step thru the original image data and create a
new image of 16bit texels.
I then use setImage in the following way:
tex = new(arena) pfTexture;
tex->setFormat(PFTEX_INTERNAL_FORMAT,PFTEX_RGB_5);
where imgPtr is the 16bit data.
tex->setImage((uint *)imgPtr,2,320,240,1);
tex->setRepeat(PFTEX_WRAP,PFTEX_CLAMP);
The texture does appear when it is downloaded, but it has no red or
green components, just blue.
I am wondering if there is another mode I need to set that I am missing,
or if I have made some newbie mistake.
thanks for any and all help,
Dan
--
Dan Small, Intelligent Systems and Robotics Center
Sandia National Labs, email: desmall++at++sandia.gov
voice: 505-844-5301 fax: 505-844-6161
MS 1010 RMSEL Rm 1239 POBox 5800, ABQ, NM 87185-1010
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:54 PDT