Lines Matching refs:tga
103 static void UncompressTgaImage( u8* rawImage, SimpleTga* tga );
106 static void AdjustTgaForPaletteOffset( u8* dfData, SimpleTga* tga, u16 cMapStart );
107 static void CreateTgaColorLayer( TCFilePtr dfPtr, SimpleTga* tga );
108 static void CreateTgaAlphaLayer( TCFilePtr dfPtr, SimpleTga* tga );
109 static void CreateTgaPalTable( TCFilePtr dfPtr, SimpleTga* tga );
124 SimpleTga tga; in ReadTgaFile() local
135 *(u8*)( (u8*)(&tga) + i ) = 0; in ReadTgaFile()
139 tga.imageType = (u32)( *((u8* )( rawBits + 0x02 )) ); in ReadTgaFile()
140 tga.width = (u32)( *((u16*)( rawBits + 0x0C )) ); in ReadTgaFile()
141 tga.height = (u32)( *((u16*)( rawBits + 0x0E )) ); in ReadTgaFile()
142 tga.pixelDepth = (u32)( *((u8* )( rawBits + 0x10 )) ); // bits in ReadTgaFile()
143 tga.abpp = (u32)( *((u8* )( rawBits + 0x11 )) & (u8)(0x0F) ); // bits 0 to 3 in ReadTgaFile()
145 tga.colorMapType = (u32)( *((u8* )( rawBits + 0x01 )) ); in ReadTgaFile()
146 tga.cMapLength = (u32)( *((u16*)( rawBits + 0x05 )) ); in ReadTgaFile()
147 tga.cMapDepth = (u32)( *((u8* )( rawBits + 0x07 )) ); // bits in ReadTgaFile()
154 if( tga.imageType == 0 ) in ReadTgaFile()
165 switch( tga.cMapDepth ) in ReadTgaFile()
168 tga.cMapDepth = 0; in ReadTgaFile()
174 tga.cMapDepth >>= 3; in ReadTgaFile()
178 tga.cMapDepth = 2; in ReadTgaFile()
189 switch(tga.pixelDepth) in ReadTgaFile()
195 tga.pixelDepth >>= 3; in ReadTgaFile()
199 tga.pixelDepth = 2; in ReadTgaFile()
215 if( tga.colorMapType == 0 ) in ReadTgaFile()
226 if( (tga.imageType == 1) || (tga.imageType == 9) ) // palette is used by image in ReadTgaFile()
231 rawPaletteSize = (u32)tga.cMapDepth * (u32)tga.cMapLength; in ReadTgaFile()
236 if( (tga.width == 0) || (tga.height == 0) || (tga.pixelDepth == 0) ) in ReadTgaFile()
244 tgaImageSize = tga.width * tga.height * tga.pixelDepth; in ReadTgaFile()
252 tga.paletteDataSize = rawPaletteSize; in ReadTgaFile()
253 tga.paletteData = (u8*)calloc( 1, rawPaletteSize ); in ReadTgaFile()
258 *(u8*)( tga.paletteData + i ) = *(u8*)( rawPalette + i ); in ReadTgaFile()
266 tga.imageDataSize = tgaImageSize; in ReadTgaFile()
267 tga.imageData = (u8*)calloc( 1, tgaImageSize ); in ReadTgaFile()
272 UncompressTgaImage( rawImage, &tga ); in ReadTgaFile()
276 AdjustTgaForPaletteOffset( tga.imageData, &tga, cMapStart ); in ReadTgaFile()
280 OrientUncompressedTgaData( tga.imageData, tga.width, tga.height, in ReadTgaFile()
281 tga.pixelDepth, imageDesc ); in ReadTgaFile()
286 CreateTgaColorLayer( dfPtr, &tga ); in ReadTgaFile()
287 CreateTgaAlphaLayer( dfPtr, &tga ); in ReadTgaFile()
288 CreateTgaPalTable( dfPtr, &tga ); in ReadTgaFile()
291 if( tga.imageData != NULL ) in ReadTgaFile()
293 free( tga.imageData ); in ReadTgaFile()
294 tga.imageData = NULL; in ReadTgaFile()
297 if( tga.paletteData != NULL ) in ReadTgaFile()
299 free( tga.paletteData ); in ReadTgaFile()
300 tga.paletteData = NULL; in ReadTgaFile()
311 static void CreateTgaColorLayer( TCFilePtr dfPtr, SimpleTga* tga ) in CreateTgaColorLayer() argument
332 switch( tga->imageType ) in CreateTgaColorLayer()
340 TCSetLayerAttributes( newLayer, type, tga->width, tga->height ); in CreateTgaColorLayer()
353 pixelPtr = tga->imageData; in CreateTgaColorLayer()
355 for(row=0; row<tga->height; row++) in CreateTgaColorLayer()
357 for(col=0; col<tga->width; col++) in CreateTgaColorLayer()
360 switch(tga->imageType) in CreateTgaColorLayer()
364 switch(tga->pixelDepth) in CreateTgaColorLayer()
380 switch(tga->pixelDepth) in CreateTgaColorLayer()
409 switch(tga->pixelDepth) in CreateTgaColorLayer()
452 pixelPtr += tga->pixelDepth; in CreateTgaColorLayer()
464 static void CreateTgaAlphaLayer( TCFilePtr dfPtr, SimpleTga* tga ) in CreateTgaAlphaLayer() argument
474 if( tga->imageType == 1 ) // color-indexed in CreateTgaAlphaLayer()
479 if( tga->imageType == 2 ) // true color in CreateTgaAlphaLayer()
482 if( (tga->pixelDepth != 2) && (tga->pixelDepth != 4) ) in CreateTgaAlphaLayer()
492 TCSetLayerAttributes( newLayer, LY_IMAGE_ALPHA_A8, tga->width, tga->height ); in CreateTgaAlphaLayer()
500 pixelPtr = (u8*)(tga->imageData); in CreateTgaAlphaLayer()
501 for(row=0; row<tga->height; row++) in CreateTgaAlphaLayer()
503 for(col=0; col< tga->width; col++) in CreateTgaAlphaLayer()
506 switch(tga->imageType) in CreateTgaAlphaLayer()
511 switch(tga->pixelDepth) in CreateTgaAlphaLayer()
535 switch(tga->pixelDepth) in CreateTgaAlphaLayer()
575 pixelPtr += tga->pixelDepth; in CreateTgaAlphaLayer()
584 static void CreateTgaPalTable( TCFilePtr dfPtr, SimpleTga* tga ) in CreateTgaPalTable() argument
592 if( tga->paletteData == NULL ) in CreateTgaPalTable()
597 dfPtr->palPtr = (TCPalTable*)TCCreatePalTable( tga->cMapLength ); in CreateTgaPalTable()
599 rawPtr = tga->paletteData; in CreateTgaPalTable()
601 for(i=0; i< tga->cMapLength; i++ ) in CreateTgaPalTable()
604 switch( tga->cMapDepth ) in CreateTgaPalTable()
679 static void UncompressTgaImage( u8* rawImage, SimpleTga* tga ) in UncompressTgaImage() argument
688 switch(tga->imageType) in UncompressTgaImage()
704 size = tga->width * tga->height * tga->pixelDepth; in UncompressTgaImage()
707 UnencodeTgaImage( rawImage, tmpBuff, tga->width, tga->height, tga->pixelDepth ); in UncompressTgaImage()
716 size = tga->width * tga->height * tga->pixelDepth; in UncompressTgaImage()
717 dstPtr = tga->imageData; in UncompressTgaImage()
727 switch(tga->imageType) in UncompressTgaImage()
729 case 9: tga->imageType = 1; break; in UncompressTgaImage()
730 case 10: tga->imageType = 2; break; in UncompressTgaImage()
731 case 11: tga->imageType = 3; break; in UncompressTgaImage()
927 static void AdjustTgaForPaletteOffset( u8* dfData, SimpleTga* tga, u16 cMapStart ) in AdjustTgaForPaletteOffset() argument
939 if( (tga->imageType != 1) && (tga->imageType != 9) ) in AdjustTgaForPaletteOffset()
945 if( (tga->pixelDepth != 1) && (tga->pixelDepth != 2) ) in AdjustTgaForPaletteOffset()
952 vPtr = (void*)( tga->imageData ); in AdjustTgaForPaletteOffset()
954 for(i=0; i< tga->height; i++) in AdjustTgaForPaletteOffset()
956 for(j=0; j< tga->width; j++) in AdjustTgaForPaletteOffset()
959 if(tga->pixelDepth == 1) in AdjustTgaForPaletteOffset()
965 else if(tga->pixelDepth == 2) in AdjustTgaForPaletteOffset()