[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
This commit is contained in:
Yves Rizoud 2009-10-06 23:28:37 +00:00
parent 874ccd4430
commit 2f1888e50d
2 changed files with 37 additions and 17 deletions

View File

@ -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; i<Spare_backups->Pages->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;

30
pages.c
View File

@ -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; i<nb_layers;i++)
{
//Main_backups->Pages->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; i<nb_layers;i++)
{
memset(Spare_backups->Pages->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;
}