X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=image.c;h=c556f3930bfbc7cd0170ceaeeb439908673d9718;hb=2000fe0dea529231a494c63436f171829cbf43e5;hp=41055d7e6695bc2d391eb72e39c121f0b5bc47d8;hpb=bf54dd6e7fb965287073b669235a7b30c7f96923;p=xonotic%2Fdarkplaces.git diff --git a/image.c b/image.c index 41055d7e..c556f393 100644 --- a/image.c +++ b/image.c @@ -219,7 +219,7 @@ unsigned char* LoadPCX_BGRA (const unsigned char *f, int filesize, int *miplevel image_width = pcx.xmax + 1 - pcx.xmin; image_height = pcx.ymax + 1 - pcx.ymin; - if (pcx.manufacturer != 0x0a || pcx.version != 5 || pcx.encoding != 1 || pcx.bits_per_pixel != 8 || image_width > 4096 || image_height > 4096 || image_width <= 0 || image_height <= 0) + if (pcx.manufacturer != 0x0a || pcx.version != 5 || pcx.encoding != 1 || pcx.bits_per_pixel != 8 || image_width > 32768 || image_height > 32768 || image_width <= 0 || image_height <= 0) { Con_Print("Bad pcx file\n"); return NULL; @@ -416,7 +416,7 @@ unsigned char *LoadTGA_BGRA (const unsigned char *f, int filesize, int *miplevel targa_header.pixel_size = f[16]; targa_header.attributes = f[17]; - if (image_width > 4096 || image_height > 4096 || image_width <= 0 || image_height <= 0) + if (image_width > 32768 || image_height > 32768 || image_width <= 0 || image_height <= 0) { Con_Print("LoadTGA: invalid size\n"); PrintTargaHeader(&targa_header); @@ -759,7 +759,7 @@ unsigned char *LoadWAL_BGRA (const unsigned char *f, int filesize, int *miplevel image_width = LittleLong(inwal->width); image_height = LittleLong(inwal->height); - if (image_width > 4096 || image_height > 4096 || image_width <= 0 || image_height <= 0) + if (image_width > 32768 || image_height > 32768 || image_width <= 0 || image_height <= 0) { Con_Printf("LoadWAL: invalid size %ix%i\n", image_width, image_height); return NULL; @@ -804,7 +804,7 @@ void Image_MakeLinearColorsFromsRGB(unsigned char *pout, const unsigned char *pi // this math from http://www.opengl.org/registry/specs/EXT/texture_sRGB.txt if (!image_linearfromsrgb[255]) for (i = 0;i < 256;i++) - image_linearfromsrgb[i] = i < 11 ? (int)(i / 12.92f) : (int)(pow((i/256.0f + 0.055f)/1.0555f, 2.4)*256.0f); + image_linearfromsrgb[i] = (unsigned char)(Image_LinearFloatFromsRGB(i) * 256.0f); for (i = 0;i < numpixels;i++) { pout[i*4+0] = image_linearfromsrgb[pin[i*4+0]]; @@ -1004,14 +1004,14 @@ unsigned char *loadimagepixelsbgra (const char *filename, qboolean complain, qbo } extern cvar_t gl_picmip; -rtexture_t *loadtextureimage (rtexturepool_t *pool, const char *filename, qboolean complain, int flags, qboolean allowFixtrans, qboolean convertsRGB) +rtexture_t *loadtextureimage (rtexturepool_t *pool, const char *filename, qboolean complain, int flags, qboolean allowFixtrans, qboolean sRGB) { unsigned char *data; rtexture_t *rt; int miplevel = R_PicmipForFlags(flags); - if (!(data = loadimagepixelsbgra (filename, complain, allowFixtrans, convertsRGB, &miplevel))) + if (!(data = loadimagepixelsbgra (filename, complain, allowFixtrans, false, &miplevel))) return 0; - rt = R_LoadTexture2D(pool, filename, image_width, image_height, data, TEXTYPE_BGRA, flags, miplevel, NULL); + rt = R_LoadTexture2D(pool, filename, image_width, image_height, data, sRGB ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, flags, miplevel, NULL); Mem_Free(data); return rt; }