From f68b216eb4c35ed1e1e8b8f9a2cf644bdb5631d4 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 12 Mar 2019 02:42:46 +0100 Subject: [PATCH] original image size is accessible in texture_data --- hyper.h | 1 + textures.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hyper.h b/hyper.h index df25a6a2..ae0f5dca 100644 --- a/hyper.h +++ b/hyper.h @@ -3319,6 +3319,7 @@ namespace texture { GLuint textureid; int twidth; + int tx, ty, origdim; texture_data() { textureid = 0; twidth = 2048; } diff --git a/textures.cpp b/textures.cpp index 10daeb7f..afc85f7e 100644 --- a/textures.cpp +++ b/textures.cpp @@ -111,7 +111,7 @@ bool texture_data::readtexture(string tn) { auto txt2 = convertSurface(txt); SDL_FreeSurface(txt); - int tx = txt2->w, ty = txt2->h; + tx = txt2->w, ty = txt2->h; auto pix = [&] (int x, int y) { return qpixel(txt2, x, y); }; @@ -130,8 +130,8 @@ bool texture_data::readtexture(string tn) { // set the expected format png_infop info = png_create_info_struct(png); png_read_info(png, info); - int tx = png_get_image_width(png, info); - int ty = png_get_image_height(png, info); + tx = png_get_image_width(png, info); + ty = png_get_image_height(png, info); png_byte color_type = png_get_color_type(png, info); png_byte bit_depth = png_get_bit_depth(png, info); if(bit_depth == 16) png_set_strip_16(png); @@ -180,7 +180,7 @@ bool texture_data::readtexture(string tn) { else { - int origdim = max(tx, ty); + origdim = max(tx, ty); int base_x = tx/2 - origdim/2; int base_y = ty/2 - origdim/2;