From c53c6415c3a8cbdfb661b0240beff879f61f874c Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sun, 12 Sep 2010 14:58:25 +0000 Subject: [PATCH] Fix important bug where resizing an image or using any transformation resets transparent color to zero git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1610 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/factory.c | 5 ++++- src/pages.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/factory.c b/src/factory.c index d70a0056..3d123400 100644 --- a/src/factory.c +++ b/src/factory.c @@ -340,7 +340,10 @@ int L_GetBackupPixel(lua_State* L) lua_pushinteger(L, Main_backups->Pages->Transparent_color); return 1; } - lua_pushinteger(L, Read_pixel_from_backup_screen(x,y)); + // Can't use Read_pixel_from_backup_screen(), because in a Lua script + // the "backup" can use a different screen dimension. + lua_pushinteger(L, *(Screen_backup + x + Main_backups->Pages->Next->Width * y)); + return 1; } diff --git a/src/pages.c b/src/pages.c index 9712488d..33421c29 100644 --- a/src/pages.c +++ b/src/pages.c @@ -833,11 +833,17 @@ int Backup_with_new_dimensions(int upload,byte layers,int width,int height) return 0; } Upload_infos_page_main(new_page); - new_page->Width=width; - new_page->Height=height; + + // Other data not covered by Upload_infos_page_main. + // I dunno really why we don't use Copy_S_Page strcpy(new_page->Filename, Main_backups->Pages->Filename); strcpy(new_page->File_directory, Main_backups->Pages->File_directory); new_page->Gradients=Dup_gradient(upload?Main_backups->Pages:NULL); + new_page->Background_transparent=Main_backups->Pages->Background_transparent; + new_page->Transparent_color=Main_backups->Pages->Transparent_color; + // + new_page->Width=width; + new_page->Height=height; if (Create_new_page(new_page,Main_backups,0xFFFFFFFF)) { for (i=0; i