PSP: Pass the stream as reference to PngLoader.

This commit is contained in:
Christoph Mallon 2011-08-07 11:57:40 +02:00
parent a5675c3dbe
commit c21f87836e
4 changed files with 8 additions and 10 deletions

View file

@ -69,7 +69,7 @@ bool ImageViewer::load(int imageNum) {
assert(_renderer);
// Load a PNG into our buffer and palette. Size it by the actual size of the image
PngLoader image(file, *_buffer, *_palette, Buffer::kSizeBySourceSize);
PngLoader image(*file, *_buffer, *_palette, Buffer::kSizeBySourceSize);
PngLoader::Status status = image.allocate(); // allocate the buffers for the file

View file

@ -78,7 +78,7 @@ PngLoader::Status PngLoader::allocate() {
bool PngLoader::load() {
DEBUG_ENTER_FUNC();
// Try to load the image
_file->seek(0); // Go back to start
_file.seek(0); // Go back to start
if (!loadImageIntoBuffer()) {
PSP_DEBUG_PRINT("failed to load image\n");
@ -99,11 +99,9 @@ void PngLoader::warningFn(png_structp png_ptr, png_const_charp warning_msg) {
// Read function for png library to be able to read from our SeekableReadStream
//
void PngLoader::libReadFunc(png_structp pngPtr, png_bytep data, png_size_t length) {
Common::SeekableReadStream *file;
Common::SeekableReadStream &file = *(Common::SeekableReadStream *)pngPtr->io_ptr;
file = (Common::SeekableReadStream *)pngPtr->io_ptr;
file->read(data, length);
file.read(data, length);
}
bool PngLoader::basicImageLoad() {
@ -120,7 +118,7 @@ bool PngLoader::basicImageLoad() {
return false;
}
// Set the png lib to use our read function
png_set_read_fn(_pngPtr, (void *)_file, libReadFunc);
png_set_read_fn(_pngPtr, &_file, libReadFunc);
unsigned int sig_read = 0;

View file

@ -34,7 +34,7 @@ private:
static void warningFn(png_structp png_ptr, png_const_charp warning_msg);
static void libReadFunc(png_structp pngPtr, png_bytep data, png_size_t length);
Common::SeekableReadStream *_file;
Common::SeekableReadStream &_file;
Buffer *_buffer;
Palette *_palette;
@ -57,7 +57,7 @@ public:
BAD_FILE
};
PngLoader(Common::SeekableReadStream *file, Buffer &buffer, Palette &palette,
PngLoader(Common::SeekableReadStream &file, Buffer &buffer, Palette &palette,
Buffer::HowToSize sizeBy = Buffer::kSizeByTextureSize) :
_file(file), _buffer(&buffer), _palette(&palette),
_width(0), _height(0), _paletteSize(0),

View file

@ -298,7 +298,7 @@ bool PSPKeyboard::load() {
goto ERROR;
}
PngLoader image(file, _buffers[i], _palettes[i]);
PngLoader image(*file, _buffers[i], _palettes[i]);
if (image.allocate() != PngLoader::OK) {
PSP_ERROR("Failed to allocate memory for keyboard image %s\n", _guiStrings[i]);