Advertisement

modifing lesson 30 to work with TGA files

Started by October 24, 2001 03:47 PM
-1 comments, last by Ragendra Das 23 years, 4 months ago
the main proble I have is a alllocation error poping up before the the end of the blit here''s the code : void Blit( P_TEXTURE_IMAGE src, P_TEXTURE_IMAGE dst, int src_xstart, int src_ystart, int src_width, int src_height, int dst_xstart, int dst_ystart) { int i,j,k,l,m,n; unsigned char *s, *d, R, G, B, A; // Source & Destination d = dst->imageData + (dst_ystart * dst->width * dst->bpp); // Start Row - dst (Row * Width In Pixels * Bytes Per Pixel) s = src->imageData + (src_ystart * src->width * src->bpp); // Start Row - src (Row * Width In Pixels * Bytes Per Pixel) for (i = 0 ; i < src_height ; i++ ) // Height Loop { s = s + (src_xstart * src->bpp); // Move Through Src Data By Bytes Per Pixel d = d + (dst_xstart * dst->bpp); // Move Through Dst Data By Bytes Per Pixel for (j = 0 ; j < src_width ; j++ ) // Width Loop { if (src->bpp==32) { for (k=0;k<8;k++,s++) R = *s; // Get Red value for (l=0;l<8;l++,s++) G = *s; // Get Green value for (m=0;m<8;m++,s++); B = *s; // Get Blue Value for (n=0;n<8;n++,s++); A = *s; // Get Alpha Value *d = (R * A)+(*d * (255 - A)); // Blend Red d++; *d = (G * A)+(*d * (255 - A)); // Blend Green d++; *d = (B * A)+(*d * (255 - A)); // Blend Blue d++; } else { if (src->bpp == 24 && dst->bpp == 24) { for( k = 0 ; k < src->bpp ; k++, d++, s++) // "n" Bytes At A Time *d = *s; // No Blending Just Do A Straight Copy } else if (src->bpp == 24 && dst->bpp == 32) { for( k = 0 ; k < 24 ; k++, d++, s++) // "n" Bytes At A Time { *d = *s; // No Blending Just Do A Straight Copy *d = 255; } } } } d = d + (dst->width - (src_width + dst_xstart))*dst->bpp; // Add End Of Row */ s = s + (src->width - (src_width + src_xstart))*src->bpp; // Add End Of Row */ } } any thought ?? God''''s in his heave all is right with the world - NERVE
God''s in his heave all is right with the world - NERVE

This topic is closed to new replies.

Advertisement