Original Post
Lo all,
i have a problem encoding a rle encode tga file, i use
the following code. All input variables are set correct.
So there need to be going something wrong in this code
I hope somebody can help me, i am getting nuts after trying for about 3 to 4 hours :S
------
With kind regards,
Sander Aerts aka DrSnugels
Crap
---------------------------
mov ax, 013h; int 10h; mov ax, 0xa000h;
mov es, ax; mov di, 3360; mov al, 15;
stosb; mov ax, 0002h; int 21h;
mov ax, 03h; int 10h;
do {
fread(&tgachunkheader, 1, 1, fp);
if (tgachunkheader < 128){
/* RAW Pixel */
tgachunkheader++;
for (int cc = 0; cc < tgachunkheader; cc++){
fread(tga_pixel, 1, tgaheader.bytesperpixel, fp);
tga_temp_img.imageData[currentbyte] = tga_pixel[2];
tga_temp_img.imageData[currentbyte + 1] = tga_pixel[1];
tga_temp_img.imageData[currentbyte + 2] = tga_pixel[0];
if (tgaheader.bytesperpixel == 4)
tga_temp_img.imageData[currentbyte + 3] = tga_pixel[3];
currentbyte += tgaheader.bytesperpixel;
}
} else {
/* RLE Encoded pixel(s) */
tgachunkheader -= 127;
fread(tga_pixel, 1, tgaheader.bytesperpixel, fp);
for (int cc = 0; cc < tgachunkheader; cc++){
tga_temp_img.imageData[currentbyte] = tga_pixel[2];
tga_temp_img.imageData[currentbyte + 1] = tga_pixel[1];
tga_temp_img.imageData[currentbyte + 2] = tga_pixel[0];
if (tgaheader.bytesperpixel == 4)
tga_temp_img.imageData[currentbyte + 3] = tga_pixel[3];
currentbyte += tgaheader.bytesperpixel;
}
}
currentpixel += tgachunkheader;
} while (currentpixel < tgapixels);