Ticket #9290: pngloader.cpp.diff
File pngloader.cpp.diff, 3.5 KB (added by , 13 years ago) |
---|
-
engines/sword25/gfx/image/pngloader.cpp
old new 84 84 Common::MemoryReadStream stream(fileDataPtr, fileSize); 85 85 stream.seek(0, SEEK_SET); 86 86 87 // Headerinformationen der Spielstandes einlesen.87 // Read header information of savegame 88 88 uint compressedGamedataSize; 89 89 loadString(stream); // Marker 90 90 loadString(stream); // Version … … 124 124 error("png_check_sig failed"); 125 125 } 126 126 127 // Die beiden PNG Strukturen erstellen127 // Create both PNG structures 128 128 png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 129 129 if (!png_ptr) { 130 130 error("Could not create libpng read struct."); … … 135 135 error("Could not create libpng info struct."); 136 136 } 137 137 138 // Alternative Lesefunktion benutzen138 // Use alternative reading function 139 139 const byte **ref = &fileDataPtr; 140 140 png_set_read_fn(png_ptr, (void *)ref, png_user_read_data); 141 141 142 // PNG Header einlesen142 // Read PNG header 143 143 png_read_info(png_ptr, info_ptr); 144 144 145 // PNG Informationen auslesen145 // Read out PNG informations 146 146 147 147 png_uint_32 w, h; 148 148 png_get_IHDR(png_ptr, info_ptr, &w, &h, &bitDepth, &colorType, &interlaceType, NULL, NULL); 149 149 width = w; 150 150 height = h; 151 151 152 // Pitch des Ausgabebildes berechnen152 // Calculate pitch of output image 153 153 pitch = GraphicEngine::calcPitch(GraphicEngine::CF_ARGB32, width); 154 154 155 // Speicher für die endgültigen Bilddaten reservieren156 // Dieses geschieht vor dem reservieren von Speicher für temporäre Bilddaten um die Fragmentierung des Speichers gering zu halten155 // Allocate memory for the final image data. 156 // To keep memory framentation low this happens before allocating memory for temporary image data. 157 157 uncompressedDataPtr = new byte[pitch * height]; 158 158 if (!uncompressedDataPtr) { 159 159 error("Could not allocate memory for output image."); 160 160 } 161 161 162 // Bilder jeglicher Farbformate werden zunächst in ARGB Bilder umgewandelt162 // Images of all color formates will be transformed into ARGB images 163 163 if (bitDepth == 16) 164 164 png_set_strip_16(png_ptr); 165 165 if (colorType == PNG_COLOR_TYPE_PALETTE) … … 177 177 if (colorType != PNG_COLOR_TYPE_RGB_ALPHA) 178 178 png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); 179 179 180 // Nachdem die Transformationen registriert wurden, werden die Bilddaten erneut eingelesen180 // After the transformations have been registered, the image data is read again. 181 181 png_read_update_info(png_ptr, info_ptr); 182 182 png_get_IHDR(png_ptr, info_ptr, &w, &h, &bitDepth, &colorType, NULL, NULL, NULL); 183 183 width = w; … … 251 251 png_structp png_ptr = NULL; 252 252 png_infop info_ptr = NULL; 253 253 254 // Die beiden PNG Strukturen erstellen254 // Create both PNG structures 255 255 png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 256 256 if (!png_ptr) { 257 257 error("Could not create libpng read struct."); … … 262 262 error("Could not create libpng info struct."); 263 263 } 264 264 265 // Alternative Lesefunktion benutzen265 // Use alternative reading function 266 266 const byte **ref = &fileDataPtr; 267 267 png_set_read_fn(png_ptr, (void *)ref, png_user_read_data); 268 268 269 // PNG Header einlesen269 // Read PNG Header 270 270 png_read_info(png_ptr, info_ptr); 271 271 272 // PNG Informationen auslesen272 // Read out PNG informations 273 273 int bitDepth; 274 274 int colorType; 275 275 png_uint_32 w, h; … … 278 278 width = w; 279 279 height = h; 280 280 281 // D ie Strukturen freigeben281 // Destroy libpng structures 282 282 png_destroy_read_struct(&png_ptr, &info_ptr, NULL); 283 283 #else 284 284 // We don't need to read the image properties here...