PSP: Pass the stream as reference to PngLoader.
This commit is contained in:
parent
a5675c3dbe
commit
c21f87836e
4 changed files with 8 additions and 10 deletions
|
@ -69,7 +69,7 @@ bool ImageViewer::load(int imageNum) {
|
||||||
assert(_renderer);
|
assert(_renderer);
|
||||||
|
|
||||||
// Load a PNG into our buffer and palette. Size it by the actual size of the image
|
// 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
|
PngLoader::Status status = image.allocate(); // allocate the buffers for the file
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ PngLoader::Status PngLoader::allocate() {
|
||||||
bool PngLoader::load() {
|
bool PngLoader::load() {
|
||||||
DEBUG_ENTER_FUNC();
|
DEBUG_ENTER_FUNC();
|
||||||
// Try to load the image
|
// Try to load the image
|
||||||
_file->seek(0); // Go back to start
|
_file.seek(0); // Go back to start
|
||||||
|
|
||||||
if (!loadImageIntoBuffer()) {
|
if (!loadImageIntoBuffer()) {
|
||||||
PSP_DEBUG_PRINT("failed to load image\n");
|
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
|
// 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) {
|
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() {
|
bool PngLoader::basicImageLoad() {
|
||||||
|
@ -120,7 +118,7 @@ bool PngLoader::basicImageLoad() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Set the png lib to use our read function
|
// 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;
|
unsigned int sig_read = 0;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ private:
|
||||||
static void warningFn(png_structp png_ptr, png_const_charp warning_msg);
|
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);
|
static void libReadFunc(png_structp pngPtr, png_bytep data, png_size_t length);
|
||||||
|
|
||||||
Common::SeekableReadStream *_file;
|
Common::SeekableReadStream &_file;
|
||||||
Buffer *_buffer;
|
Buffer *_buffer;
|
||||||
Palette *_palette;
|
Palette *_palette;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public:
|
||||||
BAD_FILE
|
BAD_FILE
|
||||||
};
|
};
|
||||||
|
|
||||||
PngLoader(Common::SeekableReadStream *file, Buffer &buffer, Palette &palette,
|
PngLoader(Common::SeekableReadStream &file, Buffer &buffer, Palette &palette,
|
||||||
Buffer::HowToSize sizeBy = Buffer::kSizeByTextureSize) :
|
Buffer::HowToSize sizeBy = Buffer::kSizeByTextureSize) :
|
||||||
_file(file), _buffer(&buffer), _palette(&palette),
|
_file(file), _buffer(&buffer), _palette(&palette),
|
||||||
_width(0), _height(0), _paletteSize(0),
|
_width(0), _height(0), _paletteSize(0),
|
||||||
|
|
|
@ -298,7 +298,7 @@ bool PSPKeyboard::load() {
|
||||||
goto ERROR;
|
goto ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
PngLoader image(file, _buffers[i], _palettes[i]);
|
PngLoader image(*file, _buffers[i], _palettes[i]);
|
||||||
|
|
||||||
if (image.allocate() != PngLoader::OK) {
|
if (image.allocate() != PngLoader::OK) {
|
||||||
PSP_ERROR("Failed to allocate memory for keyboard image %s\n", _guiStrings[i]);
|
PSP_ERROR("Failed to allocate memory for keyboard image %s\n", _guiStrings[i]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue