1111#include " _lib/jpeglib.h"
1212#include " _lib/tiffio.h"
1313#include " _lib/png.h"
14- #ifndef __bool_true_false_are_defined
15- #define __bool_true_false_are_defined
16- #endif
1714#include " _lib/gif_lib.h"
1815
1916// =======
@@ -61,22 +58,22 @@ void image_c::Free()
6158 dat = NULL ;
6259}
6360
64- bool image_c::Load (char * fileName)
61+ bool image_c::Load (const char * fileName)
6562{
6663 return true ; // o_O
6764}
6865
69- bool image_c::Save (char * fileName)
66+ bool image_c::Save (const char * fileName)
7067{
7168 return true ; // o_O
7269}
7370
74- bool image_c::ImageInfo (char * fileName, imageInfo_s* info)
71+ bool image_c::ImageInfo (const char * fileName, imageInfo_s* info)
7572{
7673 return true ; // o_O
7774}
7875
79- image_c* image_c::LoaderForFile (IConsole* conHnd, char * fileName)
76+ image_c* image_c::LoaderForFile (IConsole* conHnd, const char * fileName)
8077{
8178 fileInputStream_c in;
8279 if (in.FileOpen (fileName, true )) {
@@ -131,7 +128,7 @@ struct tgaHeader_s {
131128};
132129#pragma pack(pop)
133130
134- bool targa_c::Load (char * fileName)
131+ bool targa_c::Load (const char * fileName)
135132{
136133 Free ();
137134
@@ -214,7 +211,7 @@ bool targa_c::Load(char* fileName)
214211 return false ;
215212}
216213
217- bool targa_c::Save (char * fileName)
214+ bool targa_c::Save (const char * fileName)
218215{
219216 // Find a suitable image type
220217 int ittable[3 ][3 ] = {
@@ -313,7 +310,7 @@ bool targa_c::Save(char* fileName)
313310 }
314311 line.MemOutput (&out);
315312 }
316- delete packet;
313+ delete[] packet;
317314 } else {
318315 // Raw
319316 for (int y = height - 1 ; y >= 0 ; y--) {
@@ -324,7 +321,7 @@ bool targa_c::Save(char* fileName)
324321 return false ;
325322}
326323
327- bool targa_c::ImageInfo (char * fileName, imageInfo_s* info)
324+ bool targa_c::ImageInfo (const char * fileName, imageInfo_s* info)
328325{
329326 // Open the file
330327 fileInputStream_c in;
@@ -382,8 +379,8 @@ struct jpegError_s: public jpeg_error_mgr {
382379// JPEG Reading
383380
384381struct jpegRead_s : public jpeg_source_mgr {
385- ioStream_c* in;
386- byte buffer[1024 ];
382+ ioStream_c* in = nullptr ;
383+ byte buffer[1024 ] = {} ;
387384 jpegRead_s (ioStream_c* in)
388385 : in(in)
389386 {
@@ -432,7 +429,7 @@ struct jpegRead_s: public jpeg_source_mgr {
432429 }
433430};
434431
435- bool jpeg_c::Load (char * fileName)
432+ bool jpeg_c::Load (const char * fileName)
436433{
437434 Free ();
438435
@@ -486,7 +483,7 @@ bool jpeg_c::Load(char* fileName)
486483 }
487484 catch (...) {
488485 }
489- delete rows;
486+ delete[] rows;
490487
491488 jpeg_destroy_decompress (&jdecomp);
492489 return false ;
@@ -495,8 +492,8 @@ bool jpeg_c::Load(char* fileName)
495492// JPEG Writing
496493
497494struct jpegWrite_s : public jpeg_destination_mgr {
498- ioStream_c* out;
499- byte buffer[1024 ];
495+ ioStream_c* out = nullptr ;
496+ byte buffer[1024 ] = {} ;
500497 jpegWrite_s (ioStream_c* out)
501498 : out(out)
502499 {
@@ -525,7 +522,7 @@ struct jpegWrite_s: public jpeg_destination_mgr {
525522 }
526523};
527524
528- bool jpeg_c::Save (char * fileName)
525+ bool jpeg_c::Save (const char * fileName)
529526{
530527 // JPEG only supports RGB and grayscale images
531528 if (type != IMGTYPE_RGB && type != IMGTYPE_GRAY ) {
@@ -580,15 +577,15 @@ bool jpeg_c::Save(char* fileName)
580577 catch (...) {
581578 dst.Term (&jcomp);
582579 }
583- delete rows;
580+ delete[] rows;
584581
585582 jpeg_destroy_compress (&jcomp);
586583 return false ;
587584}
588585
589586// JPEG Image Info
590587
591- bool jpeg_c::ImageInfo (char * fileName, imageInfo_s* info)
588+ bool jpeg_c::ImageInfo (const char * fileName, imageInfo_s* info)
592589{
593590 // Open the file
594591 fileInputStream_c in;
@@ -677,7 +674,7 @@ static toff_t ITIFF_SizeProc(thandle_t clientData)
677674 return cd->io ->GetLen ();
678675}
679676
680- bool tiff_c::Load (char * fileName)
677+ bool tiff_c::Load (const char * fileName)
681678{
682679 Free ();
683680
@@ -712,7 +709,7 @@ bool tiff_c::Load(char* fileName)
712709 return ret;
713710}
714711
715- bool tiff_c::Save (char * fileName)
712+ bool tiff_c::Save (const char * fileName)
716713{
717714 // Only save RGB or RGBA
718715 if (type != IMGTYPE_RGB && type != IMGTYPE_RGBA ) {
@@ -753,7 +750,7 @@ bool tiff_c::Save(char* fileName)
753750 return false ;
754751}
755752
756- bool tiff_c::ImageInfo (char * fileName, imageInfo_s* info)
753+ bool tiff_c::ImageInfo (const char * fileName, imageInfo_s* info)
757754{
758755 // Open the file
759756 fileInputStream_c in;
@@ -804,7 +801,7 @@ static void IPNG_ReadProc(png_structp png, png_bytep data, png_size_t len)
804801 }
805802}
806803
807- bool png_c::Load (char * fileName)
804+ bool png_c::Load (const char * fileName)
808805{
809806 Free ();
810807
@@ -875,7 +872,7 @@ static void IPNG_FlushProc(png_structp png)
875872 out->FileFlush ();
876873}
877874
878- bool png_c::Save (char * fileName)
875+ bool png_c::Save (const char * fileName)
879876{
880877 if (type != IMGTYPE_RGB && type != IMGTYPE_RGBA ) {
881878 return true ;
@@ -907,15 +904,15 @@ bool png_c::Save(char* fileName)
907904 }
908905 png_set_rows (png, pnginfo, rows);
909906 png_write_png (png, pnginfo, PNG_TRANSFORM_IDENTITY , NULL );
910- delete rows;
907+ delete[] rows;
911908
912909 png_destroy_write_struct (&png, &pnginfo);
913910 return false ;
914911}
915912
916913// PNG Image Info
917914
918- bool png_c::ImageInfo (char * fileName, imageInfo_s* info)
915+ bool png_c::ImageInfo (const char * fileName, imageInfo_s* info)
919916{
920917 // Open file and check signature
921918 fileInputStream_c in;
@@ -973,7 +970,7 @@ static int IGIF_ReadProc(GifFileType* gif, GifByteType* buf, int len)
973970 return len;
974971}
975972
976- bool gif_c::Load (char * fileName)
973+ bool gif_c::Load (const char * fileName)
977974{
978975 // Open file
979976 fileInputStream_c in;
@@ -1025,13 +1022,13 @@ bool gif_c::Load(char* fileName)
10251022 return false ;
10261023}
10271024
1028- bool gif_c::Save (char * fileName)
1025+ bool gif_c::Save (const char * fileName)
10291026{
10301027 // HELL no.
10311028 return true ;
10321029}
10331030
1034- bool gif_c::ImageInfo (char * fileName, imageInfo_s* info)
1031+ bool gif_c::ImageInfo (const char * fileName, imageInfo_s* info)
10351032{
10361033 return true ;
10371034}
@@ -1063,7 +1060,7 @@ struct blpMipmapHeader_s {
10631060};
10641061#pragma pack(pop)
10651062
1066- bool blp_c::Load (char * fileName)
1063+ bool blp_c::Load (const char * fileName)
10671064{
10681065 Free ();
10691066
@@ -1113,7 +1110,7 @@ bool blp_c::Load(char* fileName)
11131110
11141111 // Read image
11151112 int isize = 0 ;
1116- int numMip;
1113+ int numMip = 0 ;
11171114 for (int c = 0 ; c < 16 ; c++) {
11181115 if (mip.size [c] == 0 ) {
11191116 numMip = c;
@@ -1134,13 +1131,13 @@ bool blp_c::Load(char* fileName)
11341131 return false ;
11351132}
11361133
1137- bool blp_c::Save (char * fileName)
1134+ bool blp_c::Save (const char * fileName)
11381135{
11391136 // No.
11401137 return true ;
11411138}
11421139
1143- bool blp_c::ImageInfo (char * fileName, imageInfo_s* info)
1140+ bool blp_c::ImageInfo (const char * fileName, imageInfo_s* info)
11441141{
11451142 // Open the file
11461143 fileInputStream_c in;
0 commit comments