From 2f1888e50d4908d39bd7ece5fa0a58c7c14887cb Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Tue, 6 Oct 2009 23:28:37 +0000 Subject: [PATCH] [layers] Implemented 'Copy to spare - pixels'. It replaces the current layer in the spare, resizing the whole spare (all layers) as needed. git-svn-id: svn://pulkomandy.tk/GrafX2/branches/layers@1064 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- buttons.c | 24 ++++++++++++++++++++++-- pages.c | 30 +++++++++++++++--------------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/buttons.c b/buttons.c index 74edc017..b14340cf 100644 --- a/buttons.c +++ b/buttons.c @@ -1382,18 +1382,38 @@ void Button_Page(void) void Copy_image_only(void) { + word old_width=Spare_image_width; + word old_height=Spare_image_height; + if (Backup_and_resize_the_spare(Main_image_width,Main_image_height)) { - // copie de l'image - memcpy(Spare_screen,Main_screen,Main_image_width*Main_image_height); + byte i; + for (i=0; iPages->Nb_layers; i++) + { + if (i == Spare_current_layer) + { + // Copy the current layer + memcpy(Spare_backups->Pages->Image[i],Main_backups->Pages->Image[Main_current_layer],Main_image_width*Main_image_height); + } + else + { + // Resize the original layer + Copy_part_of_image_to_another( + Spare_backups->Pages->Next->Image[i],0,0,Min(old_width,Spare_image_width), + Min(old_height,Spare_image_height),old_width, + Spare_backups->Pages->Image[i],0,0,Spare_image_width); + } + } // Copie des dimensions de l'image /* C'est inutile, le "Backuper et redimensionner brouillon" a déjà modifié ces valeurs pour qu'elles soient correctes. */ + /* Spare_image_width=Main_image_width; Spare_image_height=Main_image_height; + */ // Copie des décalages de la fenêtre principale (non zoomée) de l'image Spare_offset_X=Main_offset_X; diff --git a/pages.c b/pages.c index 8e8a3fc1..cfa6c84d 100644 --- a/pages.c +++ b/pages.c @@ -682,7 +682,6 @@ int Backup_with_new_dimensions(int upload,int width,int height) Error(0); return 0; } - //Copy_S_page(new_page,Main_backups->Pages); Upload_infos_page_main(new_page); new_page->Width=width; new_page->Height=height; @@ -690,7 +689,6 @@ int Backup_with_new_dimensions(int upload,int width,int height) { for (i=0; iPages->Image[i]=(byte *)malloc(width*height); memset(Main_backups->Pages->Image[i], 0, width*height); } @@ -698,15 +696,9 @@ int Backup_with_new_dimensions(int upload,int width,int height) Download_infos_page_main(Main_backups->Pages); Download_infos_backup(Main_backups); - // On nettoie la nouvelle image: - //memset(Main_screen,0,width*height); return_code=1; } - - // On détruit le descripteur de la page courante - //free(new_page); - return return_code; } @@ -717,31 +709,39 @@ int Backup_and_resize_the_spare(int width,int height) T_Page * new_page; int return_code=0; + byte nb_layers; + // On remet à jour l'état des infos de la page de brouillon (pour pouvoir // les retrouver plus tard) Upload_infos_page_spare(Spare_backups->Pages); + nb_layers=Spare_backups->Pages->Nb_layers; // On crée un descripteur pour la nouvelle page de brouillon - new_page=New_page(Spare_backups->Pages->Nb_layers); + new_page=New_page(nb_layers); if (!new_page) { Error(0); return 0; } - Upload_infos_page_spare(new_page); new_page->Width=width; new_page->Height=height; if (Create_new_page(new_page,Spare_backups,255)) { - Download_infos_page_spare(new_page); + byte i; + + for (i=0; iPages->Image[i], 0, width*height); + } + + // Update_buffers(width, height); // Not for spare + + Download_infos_page_spare(Spare_backups->Pages); + return_code=1; } - - // On détruit le descripteur de la page courante - free(new_page); - return return_code; }