void PrintTargaHeader(TargaHeader *t)
{
- Con_Print("TargaHeader:\n");
- Con_Printf("uint8 id_length = %i;\n", t->id_length);
- Con_Printf("uint8 colormap_type = %i;\n", t->colormap_type);
- Con_Printf("uint8 image_type = %i;\n", t->image_type);
- Con_Printf("uint16 colormap_index = %i;\n", t->colormap_index);
- Con_Printf("uint16 colormap_length = %i;\n", t->colormap_length);
- Con_Printf("uint8 colormap_size = %i;\n", t->colormap_size);
- Con_Printf("uint16 x_origin = %i;\n", t->x_origin);
- Con_Printf("uint16 y_origin = %i;\n", t->y_origin);
- Con_Printf("uint16 width = %i;\n", t->width);
- Con_Printf("uint16 height = %i;\n", t->height);
- Con_Printf("uint8 pixel_size = %i;\n", t->pixel_size);
- Con_Printf("uint8 attributes = %i;\n", t->attributes);
+ Con_Printf("TargaHeader:\nuint8 id_length = %i;\nuint8 colormap_type = %i;\nuint8 image_type = %i;\nuint16 colormap_index = %i;\nuint16 colormap_length = %i;\nuint8 colormap_size = %i;\nuint16 x_origin = %i;\nuint16 y_origin = %i;\nuint16 width = %i;\nuint16 height = %i;\nuint8 pixel_size = %i;\nuint8 attributes = %i;\n", t->id_length, t->colormap_type, t->image_type, t->colormap_index, t->colormap_length, t->colormap_size, t->x_origin, t->y_origin, t->width, t->height, t->pixel_size, t->attributes);
}
/*
int x, y, row_inc, compressed, readpixelcount, red, green, blue, alpha, runlen, pindex, alphabits;
qbyte *pixbuf, *image_rgba;
const qbyte *fin, *enddata;
+ unsigned char *p;
TargaHeader targa_header;
- unsigned char palette[256*4], *p;
+ unsigned char palette[256*4];
if (fs_filesize < 19)
return NULL;
return NULL;
}
+ // number of attribute bits per pixel, we only support 0 or 8
+ alphabits = targa_header.attributes & 0x0F;
+ if (alphabits != 8 && alphabits != 0)
+ {
+ Con_Print("LoadTGA: only 0 or 8 attribute (alpha) bits supported\n");
+ return NULL;
+ }
+
image_rgba = Mem_Alloc(tempmempool, image_width * image_height * 4);
if (!image_rgba)
{
row_inc = 0;
}
- // number of attribute bits per pixel, we only support 0 or 8
- alphabits = targa_header.attributes & 0x0F;
- if (alphabits != 8 && alphabits != 0)
- {
- Con_Print("LoadTGA: only 0 or 8 attribute (alpha) bits supported\n");
- return NULL;
- }
-
compressed = targa_header.image_type == 9 || targa_header.image_type == 10 || targa_header.image_type == 11;
x = 0;
y = 0;
if ((matchwidth && image_width != matchwidth) || (matchheight && image_height != matchheight))
return NULL;
- if (fs_filesize < 8 + image_width * image_height)
+ if (fs_filesize < (fs_offset_t)(8 + image_width * image_height))
{
Con_Print("LoadLMP: invalid LMP file\n");
return NULL;
char basename[MAX_QPATH], name[MAX_QPATH], *c;
if (developer_memorydebug.integer)
Mem_CheckSentinelsGlobal();
- Image_StripImageExtension(filename, basename); // strip filename extensions to allow replacement by other types
+ if (developer_texturelogging.integer)
+ Log_Printf("textures.log", "%s\n", filename);
+ strlcpy(basename, filename, sizeof(basename));
+ Image_StripImageExtension(basename, basename); // strip filename extensions to allow replacement by other types
// replace *'s with #, so commandline utils don't get confused when dealing with the external files
for (c = basename;*c;c++)
if (*c == '*')
void Image_Resample (const void *indata, int inwidth, int inheight, int indepth, void *outdata, int outwidth, int outheight, int outdepth, int bytesperpixel, int quality)
{
if (indepth != 1 || outdepth != 1)
- Sys_Error("Image_Resample: 3D resampling not supported\n");
+ {
+ Con_Printf ("Image_Resample: 3D resampling not supported\n");
+ return;
+ }
if (bytesperpixel == 4)
{
if (quality)
Image_Resample24Nolerp(indata, inwidth, inheight, outdata, outwidth, outheight);
}
else
- Sys_Error("Image_Resample: unsupported bytesperpixel %i\n", bytesperpixel);
+ Con_Printf ("Image_Resample: unsupported bytesperpixel %i\n", bytesperpixel);
}
// in can be the same as out
{
int x, y, nextrow;
if (*depth != 1 || destdepth != 1)
- Sys_Error("Image_Resample: 3D resampling not supported\n");
+ {
+ Con_Printf ("Image_Resample: 3D resampling not supported\n");
+ return;
+ }
nextrow = *width * bytesperpixel;
if (*width > destwidth)
{
}
}
else
- Sys_Error("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
+ Con_Printf ("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
}
else
{
}
}
else
- Sys_Error("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
+ Con_Printf ("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
}
}
else
}
}
else
- Sys_Error("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
+ Con_Printf ("Image_MipReduce: unsupported bytesperpixel %i\n", bytesperpixel);
}
else
- Sys_Error("Image_MipReduce: desired size already achieved\n");
+ Con_Printf ("Image_MipReduce: desired size already achieved\n");
}
}
n[1] = dv[0][2]*dv[1][0]-dv[0][0]*dv[1][2];
n[2] = dv[0][0]*dv[1][1]-dv[0][1]*dv[1][0];
*/
- n[0] = ((p1[0] + p1[1] + p1[2]) - (p0[0] + p0[1] + p0[2]));
- n[1] = ((p0[0] + p0[1] + p0[2]) - (p2[0] + p2[1] + p2[2]));
+ n[0] = ((p0[0] + p0[1] + p0[2]) - (p1[0] + p1[1] + p1[2]));
+ n[1] = ((p2[0] + p2[1] + p2[2]) - (p0[0] + p0[1] + p0[2]));
n[2] = ibumpscale;
VectorNormalize(n);
/*
qbyte *bumppixels;
int bumppixels_width, bumppixels_height;
char name[MAX_QPATH];
- Image_StripImageExtension(shadername, name);
+ strlcpy(name, shadername, sizeof(name));
+ Image_StripImageExtension(name, name);
memset(s, 0, sizeof(*s));
s->basepixels = loadimagepixels(name, false, 0, 0);
if (s->basepixels == NULL)