First svn commit of the experiment with layers. Preemptive backup (to shorten delay before drawing) is currently disabled. Basic Undo/Redo works, but not image resizing, the adjust tool, and saving (not even flattened)
git-svn-id: svn://pulkomandy.tk/GrafX2/branches/layers@1039 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									faea65e62b
								
							
						
					
					
						commit
						cedb706326
					
				
							
								
								
									
										7
									
								
								brush.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								brush.c
									
									
									
									
									
								
							@ -728,8 +728,7 @@ void Capture_brush(short start_x,short start_y,short end_x,short end_y,short cle
 | 
			
		||||
      for (y_pos=start_y;y_pos<start_y+Brush_height;y_pos++)
 | 
			
		||||
        for (x_pos=start_x;x_pos<start_x+Brush_width;x_pos++)
 | 
			
		||||
        {
 | 
			
		||||
          Pixel_in_current_screen(x_pos,y_pos,Back_color);
 | 
			
		||||
          Pixel_preview           (x_pos,y_pos,Back_color);
 | 
			
		||||
          Pixel_in_current_screen(x_pos,y_pos,Back_color,1);
 | 
			
		||||
        }
 | 
			
		||||
      Update_part_of_screen(start_x,start_y,Brush_width,Brush_height);
 | 
			
		||||
    }
 | 
			
		||||
@ -1154,10 +1153,10 @@ void Capture_brush_with_lasso(int vertices, short * points,short clear)
 | 
			
		||||
      for (x_pos=start_x;x_pos<=end_x;x_pos++)
 | 
			
		||||
        if (Read_pixel_from_brush(x_pos-start_x,y_pos-start_y)!=Back_color)
 | 
			
		||||
        {
 | 
			
		||||
          Pixel_in_brush(x_pos-start_x,y_pos-start_y,Read_pixel_from_current_screen(x_pos,y_pos));
 | 
			
		||||
          Pixel_in_brush(x_pos-start_x,y_pos-start_y,Read_pixel_from_current_layer(x_pos,y_pos));
 | 
			
		||||
          // On regarde s'il faut effacer quelque chose:
 | 
			
		||||
          if (clear)
 | 
			
		||||
            Pixel_in_current_screen(x_pos,y_pos,Back_color);
 | 
			
		||||
            Pixel_in_current_screen(x_pos,y_pos,Back_color,0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    // On centre la prise sur la brosse
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										93
									
								
								buttons.c
									
									
									
									
									
								
							
							
						
						
									
										93
									
								
								buttons.c
									
									
									
									
									
								
							@ -1319,7 +1319,7 @@ void Button_Page(void)
 | 
			
		||||
{
 | 
			
		||||
	byte   factor_index;
 | 
			
		||||
  char   Temp_buffer[256];
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
  #define SWAP_BYTES(a,b) { byte c=a; a=b; b=c;}
 | 
			
		||||
  #define SWAP_WORDS(a,b) { word c=a; a=b; b=c;}
 | 
			
		||||
  #define SWAP_SHORTS(a,b) { short c=a; a=b; b=c;}
 | 
			
		||||
@ -1351,14 +1351,16 @@ void Button_Page(void)
 | 
			
		||||
  SWAP_BYTES (Main_image_is_modified,Spare_image_is_modified)
 | 
			
		||||
 | 
			
		||||
  // Swap des infos sur les fileselects
 | 
			
		||||
  strcpy(Temp_buffer             ,Spare_current_directory);
 | 
			
		||||
  strcpy(Temp_buffer            ,Spare_current_directory);
 | 
			
		||||
  strcpy(Spare_current_directory,Main_current_directory);
 | 
			
		||||
  strcpy(Main_current_directory,Temp_buffer             );
 | 
			
		||||
 | 
			
		||||
  SWAP_BYTES (Main_format,Spare_format)
 | 
			
		||||
  SWAP_WORDS (Main_fileselector_position,Spare_fileselector_position)
 | 
			
		||||
  SWAP_WORDS (Main_fileselector_offset,Spare_fileselector_offset)
 | 
			
		||||
  
 | 
			
		||||
  SWAP_SHORTS(Main_current_layer,Spare_current_layer)
 | 
			
		||||
  SWAP_BYTES (Main_layers_visible,Spare_layers_visible)
 | 
			
		||||
 | 
			
		||||
  // A la fin, on affiche l'écran
 | 
			
		||||
  for (factor_index=0; ZOOM_FACTOR[factor_index]!=Main_magnifier_factor; factor_index++);
 | 
			
		||||
  Change_magnifier_factor(factor_index);
 | 
			
		||||
@ -1503,10 +1505,10 @@ void Button_Copy_page(void)
 | 
			
		||||
// -- Suppression d'une page -------------------------------------------------
 | 
			
		||||
void Button_Kill(void)
 | 
			
		||||
{
 | 
			
		||||
  if ( (Main_backups->Nb_pages_allocated==1)
 | 
			
		||||
  if ( (Main_backups->List_size==1)
 | 
			
		||||
    || (!Confirmation_box("Delete the current page?")) )
 | 
			
		||||
  {
 | 
			
		||||
    if (Main_backups->Nb_pages_allocated==1)
 | 
			
		||||
    if (Main_backups->List_size==1)
 | 
			
		||||
      Warning_message("You can't delete the last page.");
 | 
			
		||||
    Hide_cursor();
 | 
			
		||||
    Unselect_button(BUTTON_KILL);
 | 
			
		||||
@ -2540,33 +2542,33 @@ void Button_Paintbrush_menu(void)
 | 
			
		||||
        Hide_cursor();
 | 
			
		||||
        Display_stored_brush_in_window(x_pos+2, y_pos+2, index);
 | 
			
		||||
        Display_cursor();
 | 
			
		||||
      }
 | 
			
		||||
  }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        // Restore and exit
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
        if (Restore_brush(index))
 | 
			
		||||
        {
 | 
			
		||||
          Close_window();
 | 
			
		||||
  Close_window();
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    else if (clicked_button>1 && Window_attribute1==LEFT_SIDE)
 | 
			
		||||
    // Standard paintbrushes
 | 
			
		||||
    {
 | 
			
		||||
  {
 | 
			
		||||
      Close_window();
 | 
			
		||||
      index=clicked_button-2;
 | 
			
		||||
      Paintbrush_shape=Gfx->Paintbrush_type[index];
 | 
			
		||||
      Paintbrush_width=Gfx->Preset_paintbrush_width[index];
 | 
			
		||||
      Paintbrush_height=Gfx->Preset_paintbrush_height[index];
 | 
			
		||||
      Paintbrush_offset_X=Gfx->Preset_paintbrush_offset_X[index];
 | 
			
		||||
      Paintbrush_offset_Y=Gfx->Preset_paintbrush_offset_Y[index];
 | 
			
		||||
      for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
 | 
			
		||||
        for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
 | 
			
		||||
          Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=Gfx->Paintbrush_sprite[index][y_pos][x_pos];
 | 
			
		||||
      Change_paintbrush_shape(Gfx->Paintbrush_type[index]);
 | 
			
		||||
    index=clicked_button-2;
 | 
			
		||||
    Paintbrush_shape=Gfx->Paintbrush_type[index];
 | 
			
		||||
    Paintbrush_width=Gfx->Preset_paintbrush_width[index];
 | 
			
		||||
    Paintbrush_height=Gfx->Preset_paintbrush_height[index];
 | 
			
		||||
    Paintbrush_offset_X=Gfx->Preset_paintbrush_offset_X[index];
 | 
			
		||||
    Paintbrush_offset_Y=Gfx->Preset_paintbrush_offset_Y[index];
 | 
			
		||||
    for (y_pos=0; y_pos<Paintbrush_height; y_pos++)
 | 
			
		||||
      for (x_pos=0; x_pos<Paintbrush_width; x_pos++)
 | 
			
		||||
        Paintbrush_sprite[(y_pos*MAX_PAINTBRUSH_SIZE)+x_pos]=Gfx->Paintbrush_sprite[index][y_pos][x_pos];
 | 
			
		||||
    Change_paintbrush_shape(Gfx->Paintbrush_type[index]);
 | 
			
		||||
      
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
@ -4254,6 +4256,45 @@ void Transparency_set(byte amount)
 | 
			
		||||
  Compute_colorize_table();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Layer_activate(short layer, short side)
 | 
			
		||||
{
 | 
			
		||||
  if (side == RIGHT_SIDE)
 | 
			
		||||
  {
 | 
			
		||||
    // Right-click on current layer
 | 
			
		||||
    if (Main_current_layer == layer)
 | 
			
		||||
    {
 | 
			
		||||
      if (Main_layers_visible == (1<<layer))
 | 
			
		||||
      {
 | 
			
		||||
        // Set all layers visible
 | 
			
		||||
        Main_layers_visible = 0xFF;
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        // Set only this one visible
 | 
			
		||||
        Main_layers_visible = 1<<layer;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      // Right-click on an other layer : toggle its visibility
 | 
			
		||||
      Main_layers_visible ^= 1<<layer;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    // Left-click on any layer
 | 
			
		||||
    Main_current_layer = layer;
 | 
			
		||||
    Main_layers_visible |= 1<<layer;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Hide_cursor();
 | 
			
		||||
  Redraw_layered_image();
 | 
			
		||||
  //Download_infos_page_main(Main_backups->Pages);
 | 
			
		||||
  //Download_infos_backup(Main_backups);
 | 
			
		||||
  Display_all_screen();
 | 
			
		||||
  Display_cursor();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//---------------------------- Courbes de Bézier ----------------------------
 | 
			
		||||
 | 
			
		||||
void Button_Curves(void)
 | 
			
		||||
@ -5442,9 +5483,11 @@ void Button_Effects(void)
 | 
			
		||||
        break;
 | 
			
		||||
      case 13 : // Feedback (pour Colorize et Shade)
 | 
			
		||||
        if ((Config.FX_Feedback=!Config.FX_Feedback)) //!!!
 | 
			
		||||
          FX_feedback_screen=Main_screen;
 | 
			
		||||
          FX_feedback_screen=Main_backups->Pages->Image[Main_current_layer];
 | 
			
		||||
          // Main_screen
 | 
			
		||||
        else
 | 
			
		||||
          FX_feedback_screen=Screen_backup;
 | 
			
		||||
          FX_feedback_screen=Main_backups->Pages->Next->Image[Main_current_layer];
 | 
			
		||||
          // Screen_backup
 | 
			
		||||
        Hide_cursor();
 | 
			
		||||
        Display_feedback_state();
 | 
			
		||||
        Display_cursor();
 | 
			
		||||
@ -5752,10 +5795,10 @@ void Display_stored_brush_in_window(word x_pos,word y_pos,int index)
 | 
			
		||||
      offset_y = (BRUSH_CONTAINER_PREVIEW_HEIGHT-Brush_container[index].Height)/2;
 | 
			
		||||
    // Determine corner pixel of paintbrush to draw (if bigger than preview area) 
 | 
			
		||||
    //
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    // Clear
 | 
			
		||||
    Window_rectangle(x_pos,y_pos,BRUSH_CONTAINER_PREVIEW_WIDTH,BRUSH_CONTAINER_PREVIEW_HEIGHT,MC_Light);
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    // Draw up to 16x16
 | 
			
		||||
    for (y=0; y<Brush_container[index].Height && y<BRUSH_CONTAINER_PREVIEW_HEIGHT; y++)
 | 
			
		||||
    {
 | 
			
		||||
@ -5965,4 +6008,4 @@ void Button_Brush_container(void)
 | 
			
		||||
 | 
			
		||||
  //Unselect_button(BUTTON_PAINTBRUSHES);
 | 
			
		||||
  Display_cursor();
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -441,6 +441,8 @@ void Effects_off(void);
 | 
			
		||||
*/
 | 
			
		||||
void Transparency_set(byte amount);
 | 
			
		||||
 | 
			
		||||
void Layer_activate(short layer, short side);
 | 
			
		||||
 | 
			
		||||
// Menu des effets
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								const.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								const.h
									
									
									
									
									
								
							@ -64,7 +64,7 @@
 | 
			
		||||
#define LEFT_TRIANGLE_CHARACTER   17
 | 
			
		||||
/// Character to display in menus for an ellipsis.
 | 
			
		||||
#define ELLIPSIS_CHARACTER       '…'
 | 
			
		||||
 | 
			
		||||
#define NB_LAYERS                 8
 | 
			
		||||
#define BRUSH_CONTAINER_PREVIEW_WIDTH    16  ///< Size for preview of a brush in Brush container
 | 
			
		||||
#define BRUSH_CONTAINER_PREVIEW_HEIGHT   16  ///< Size for preview of a brush in Brush container
 | 
			
		||||
#define BRUSH_CONTAINER_COLUMNS          4  ///< Number of columns in the Brush container
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										24
									
								
								engine.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								engine.c
									
									
									
									
									
								
							@ -870,35 +870,43 @@ void Main_handler(void)
 | 
			
		||||
          Key=0;
 | 
			
		||||
          break;
 | 
			
		||||
        case SPECIAL_TRANSPARENCY_1 :
 | 
			
		||||
          Transparency_set(1);
 | 
			
		||||
          Layer_activate(0, LEFT_SIDE);
 | 
			
		||||
          //Transparency_set(1);
 | 
			
		||||
          Key=0;
 | 
			
		||||
          break;
 | 
			
		||||
        case SPECIAL_TRANSPARENCY_2 :
 | 
			
		||||
          Transparency_set(2);
 | 
			
		||||
          Layer_activate(1, LEFT_SIDE);
 | 
			
		||||
          //Transparency_set(2);
 | 
			
		||||
          Key=0;
 | 
			
		||||
          break;
 | 
			
		||||
        case SPECIAL_TRANSPARENCY_3 :
 | 
			
		||||
          Transparency_set(3);
 | 
			
		||||
          Layer_activate(2, LEFT_SIDE);
 | 
			
		||||
          //Transparency_set(3);
 | 
			
		||||
          Key=0;
 | 
			
		||||
          break;
 | 
			
		||||
        case SPECIAL_TRANSPARENCY_4 :
 | 
			
		||||
          Transparency_set(4);
 | 
			
		||||
          Layer_activate(3, LEFT_SIDE);
 | 
			
		||||
          //Transparency_set(4);
 | 
			
		||||
          Key=0;
 | 
			
		||||
          break;
 | 
			
		||||
        case SPECIAL_TRANSPARENCY_5 :
 | 
			
		||||
          Transparency_set(5);
 | 
			
		||||
          Layer_activate(0, RIGHT_SIDE);
 | 
			
		||||
          //Transparency_set(5);
 | 
			
		||||
          Key=0;
 | 
			
		||||
          break;
 | 
			
		||||
        case SPECIAL_TRANSPARENCY_6 :
 | 
			
		||||
          Transparency_set(6);
 | 
			
		||||
          Layer_activate(1, RIGHT_SIDE);
 | 
			
		||||
          //Transparency_set(6);
 | 
			
		||||
          Key=0;
 | 
			
		||||
          break;
 | 
			
		||||
        case SPECIAL_TRANSPARENCY_7 :
 | 
			
		||||
          Transparency_set(7);
 | 
			
		||||
          Layer_activate(2, RIGHT_SIDE);
 | 
			
		||||
          //Transparency_set(7);
 | 
			
		||||
          Key=0;
 | 
			
		||||
          break;
 | 
			
		||||
        case SPECIAL_TRANSPARENCY_8 :
 | 
			
		||||
          Transparency_set(8);
 | 
			
		||||
          Layer_activate(3, RIGHT_SIDE);
 | 
			
		||||
          //Transparency_set(8);
 | 
			
		||||
          Key=0;
 | 
			
		||||
          break;
 | 
			
		||||
        case SPECIAL_TRANSPARENCY_9 :
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								global.h
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								global.h
									
									
									
									
									
								
							@ -345,6 +345,10 @@ GFX2_GLOBAL word  Main_magnifier_width;
 | 
			
		||||
GFX2_GLOBAL short Main_magnifier_offset_X;
 | 
			
		||||
/// Y position (in image space) of the pixel to display in the top left corner of the magnified view.
 | 
			
		||||
GFX2_GLOBAL short Main_magnifier_offset_Y;
 | 
			
		||||
/// Index of layer currently being edited
 | 
			
		||||
GFX2_GLOBAL int Main_current_layer;
 | 
			
		||||
/// Bitfield that records which layers are visible. 2^0 for 0, 2^1 for 1, 2^2 for 2, etc.
 | 
			
		||||
GFX2_GLOBAL byte Main_layers_visible;
 | 
			
		||||
 | 
			
		||||
// -- Spare page data
 | 
			
		||||
 | 
			
		||||
@ -405,7 +409,10 @@ GFX2_GLOBAL word  Spare_magnifier_width;
 | 
			
		||||
GFX2_GLOBAL short Spare_magnifier_offset_X;
 | 
			
		||||
/// Y position (in image space) of the pixel to display in the top left corner of the magnified view.
 | 
			
		||||
GFX2_GLOBAL short Spare_magnifier_offset_Y;
 | 
			
		||||
 | 
			
		||||
/// Index of layer currently being edited
 | 
			
		||||
GFX2_GLOBAL short Spare_current_layer;
 | 
			
		||||
/// Bitfield that records which layers are visible. 2^0 for 0, 2^1 for 1, 2^2 for 2, etc.
 | 
			
		||||
GFX2_GLOBAL byte Spare_layers_visible;
 | 
			
		||||
// -- Image backups
 | 
			
		||||
 | 
			
		||||
/// Backup of the current screen, used during drawing when FX feedback is OFF.
 | 
			
		||||
@ -415,6 +422,15 @@ GFX2_GLOBAL T_List_of_pages * Main_backups;
 | 
			
		||||
/// List of backup pages for the spare page.
 | 
			
		||||
GFX2_GLOBAL T_List_of_pages * Spare_backups;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// -- Layers data
 | 
			
		||||
 | 
			
		||||
/// Array of two images, that contains the "flattened" version of the visible layers.
 | 
			
		||||
GFX2_GLOBAL T_Image Visible_image[2];
 | 
			
		||||
GFX2_GLOBAL T_Image Visible_image_depth_buffer;
 | 
			
		||||
/// Index that is 0 or 1, it ways which of the two ::Visible_image[] contains the current image (the other contains the data from last backup)
 | 
			
		||||
GFX2_GLOBAL int Visible_image_index;
 | 
			
		||||
 | 
			
		||||
// -- Brush data
 | 
			
		||||
 | 
			
		||||
/// Pixel data of the current brush.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								graph.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								graph.c
									
									
									
									
									
								
							@ -725,7 +725,7 @@ void Fill(short * top_reached  , short * bottom_reached,
 | 
			
		||||
  current_limit_bottom =Min(Paintbrush_Y+1,Limit_bottom);
 | 
			
		||||
  *left_reached=Paintbrush_X;
 | 
			
		||||
  *right_reached=Paintbrush_X+1;
 | 
			
		||||
  Pixel_in_current_screen(Paintbrush_X,Paintbrush_Y,2);
 | 
			
		||||
  Pixel_in_current_screen(Paintbrush_X,Paintbrush_Y,2,0);
 | 
			
		||||
 | 
			
		||||
  while (changes_made)
 | 
			
		||||
  {
 | 
			
		||||
@ -786,7 +786,7 @@ void Fill(short * top_reached  , short * bottom_reached,
 | 
			
		||||
              *right_reached=end_x;
 | 
			
		||||
            // On remplit le segment de start_x à end_x-1.
 | 
			
		||||
            for (x_pos=start_x;x_pos<end_x;x_pos++)
 | 
			
		||||
              Pixel_in_current_screen(x_pos,line,2);
 | 
			
		||||
              Pixel_in_current_screen(x_pos,line,2,0);
 | 
			
		||||
            // On vient d'effectuer des modifications.
 | 
			
		||||
            changes_made=1;
 | 
			
		||||
            line_is_modified=1;
 | 
			
		||||
@ -865,7 +865,7 @@ void Fill(short * top_reached  , short * bottom_reached,
 | 
			
		||||
              *right_reached=end_x;
 | 
			
		||||
            // On remplit le segment de start_x à end_x-1.
 | 
			
		||||
            for (x_pos=start_x;x_pos<end_x;x_pos++)
 | 
			
		||||
              Pixel_in_current_screen(x_pos,line,2);
 | 
			
		||||
              Pixel_in_current_screen(x_pos,line,2,0);
 | 
			
		||||
            // On vient d'effectuer des modifications.
 | 
			
		||||
            changes_made=1;
 | 
			
		||||
            line_is_modified=1;
 | 
			
		||||
@ -933,7 +933,7 @@ void Fill_general(byte fill_color)
 | 
			
		||||
    Replace_colors_within_limits(replace_table);
 | 
			
		||||
 | 
			
		||||
    // On fait maintenant un remplissage classique de la couleur 1 avec la 2
 | 
			
		||||
   Fill(&top_reached  ,&bottom_reached,
 | 
			
		||||
    Fill(&top_reached  ,&bottom_reached,
 | 
			
		||||
         &left_reached,&right_reached);
 | 
			
		||||
 | 
			
		||||
    //  On s'apprête à faire des opérations qui nécessitent un affichage. Il
 | 
			
		||||
@ -985,14 +985,14 @@ void Fill_general(byte fill_color)
 | 
			
		||||
          //  Ceci se fait en commençant par restaurer la couleur qu'il y avait
 | 
			
		||||
          // précédemment (c'est important pour que les effets ne s'emmèlent
 | 
			
		||||
          // pas le pinceaux)
 | 
			
		||||
          Pixel_in_current_screen(x_pos,y_pos,Read_pixel_from_backup_screen(x_pos,y_pos));
 | 
			
		||||
          Pixel_in_current_screen(x_pos,y_pos,Read_pixel_from_backup_screen(x_pos,y_pos),0);
 | 
			
		||||
 | 
			
		||||
          //  Enfin, on peut afficher le pixel, en le soumettant aux effets en
 | 
			
		||||
          // cours:
 | 
			
		||||
          Display_pixel(x_pos,y_pos,fill_color);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
          Pixel_in_current_screen(x_pos,y_pos,Read_pixel_from_backup_screen(x_pos,y_pos));
 | 
			
		||||
          Pixel_in_current_screen(x_pos,y_pos,Read_pixel_from_backup_screen(x_pos,y_pos),0);
 | 
			
		||||
 | 
			
		||||
    FX_feedback_screen=old_fx_feedback_screen;
 | 
			
		||||
 | 
			
		||||
@ -1001,7 +1001,6 @@ void Fill_general(byte fill_color)
 | 
			
		||||
    // puisque les seuls points qui ont changé dans l'image ont été raffichés
 | 
			
		||||
    // par l'utilisation de "Display_pixel()", et que les autres... eh bein
 | 
			
		||||
    // on n'y a jamais touché à l'écran les autres: ils sont donc corrects.
 | 
			
		||||
 | 
			
		||||
    if(Main_magnifier_mode)
 | 
			
		||||
    {
 | 
			
		||||
      short w,h;
 | 
			
		||||
@ -2642,8 +2641,7 @@ void Display_pixel(word x,word y,byte color)
 | 
			
		||||
    && (!((Mask_mode)    && (Mask_table[Read_pixel_from_spare_screen(x,y)]))) )
 | 
			
		||||
  {
 | 
			
		||||
    color=Effect_function(x,y,color);
 | 
			
		||||
    Pixel_in_current_screen(x,y,color);
 | 
			
		||||
    Pixel_preview(x,y,color);
 | 
			
		||||
    Pixel_in_current_screen(x,y,color,1);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -154,7 +154,7 @@ void Pixel_load_in_current_screen(word x_pos,word y_pos,byte color)
 | 
			
		||||
{
 | 
			
		||||
  //if ((x_pos>=0) && (y_pos>=0)) //Toujours vrai ?
 | 
			
		||||
  if ((x_pos<Main_image_width) && (y_pos<Main_image_height))
 | 
			
		||||
    Pixel_in_current_screen(x_pos,y_pos,color);
 | 
			
		||||
    Pixel_in_current_screen(x_pos,y_pos,color,0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -343,7 +343,7 @@ void Init_preview_24b(short width,short height,long size,int format)
 | 
			
		||||
 | 
			
		||||
    // Allocate 24bit buffer
 | 
			
		||||
    Buffer_image_24b=
 | 
			
		||||
      (T_Components *)Borrow_memory_from_page(width*height*sizeof(T_Components));
 | 
			
		||||
      (T_Components *)malloc(width*height*sizeof(T_Components));
 | 
			
		||||
    if (!Buffer_image_24b)
 | 
			
		||||
    {
 | 
			
		||||
      // Print an error message
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								main.c
									
									
									
									
									
								
							@ -360,6 +360,11 @@ int Init_program(int argc,char * argv[])
 | 
			
		||||
  Main_fileselector_position=0; // Au début, le fileselect est en haut de la liste des fichiers
 | 
			
		||||
  Main_fileselector_offset=0; // Au début, le fileselect est en haut de la liste des fichiers
 | 
			
		||||
  Main_format=0;
 | 
			
		||||
  Main_current_layer=0;
 | 
			
		||||
  Main_layers_visible=0xFF;
 | 
			
		||||
  Spare_current_layer=0;
 | 
			
		||||
  Spare_layers_visible=0xFF;
 | 
			
		||||
  
 | 
			
		||||
  Spare_fileselector_position=0;
 | 
			
		||||
  Spare_fileselector_offset=0;
 | 
			
		||||
  Spare_format=0;
 | 
			
		||||
@ -616,8 +621,19 @@ int Init_program(int argc,char * argv[])
 | 
			
		||||
  Main_image_height=Screen_height/Pixel_height;
 | 
			
		||||
  Spare_image_width=Screen_width/Pixel_width;
 | 
			
		||||
  Spare_image_height=Screen_height/Pixel_height;
 | 
			
		||||
  
 | 
			
		||||
  Visible_image[0].Width = 0;
 | 
			
		||||
  Visible_image[0].Height = 0;
 | 
			
		||||
  Visible_image[0].Image = NULL;
 | 
			
		||||
  Visible_image[1].Width = 0;
 | 
			
		||||
  Visible_image[1].Height = 0;
 | 
			
		||||
  Visible_image[1].Image = NULL;
 | 
			
		||||
  Visible_image_depth_buffer.Width = 0;
 | 
			
		||||
  Visible_image_depth_buffer.Height = 0;
 | 
			
		||||
  Visible_image_depth_buffer.Image = NULL;
 | 
			
		||||
  
 | 
			
		||||
  // Allocation de mémoire pour les différents écrans virtuels (et brosse)
 | 
			
		||||
  if (Init_all_backup_lists(Config.Max_undo_pages+1,Screen_width,Screen_height)==0)
 | 
			
		||||
  if (Init_all_backup_lists(Screen_width,Screen_height)==0)
 | 
			
		||||
    Error(ERROR_MEMORY);
 | 
			
		||||
  // On remet le nom par défaut pour la page de brouillon car il été modifié
 | 
			
		||||
  // par le passage d'un fichier en paramètre lors du traitement précédent.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										38
									
								
								misc.c
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								misc.c
									
									
									
									
									
								
							@ -219,13 +219,37 @@ byte Read_pixel_from_brush         (word x,word y)
 | 
			
		||||
 | 
			
		||||
byte Read_pixel_from_current_screen  (word x,word y)
 | 
			
		||||
{
 | 
			
		||||
	return *(Main_screen+y*Main_image_width+x);
 | 
			
		||||
  byte depth;
 | 
			
		||||
  byte color;
 | 
			
		||||
  color = *(Main_screen+y*Main_image_width+x);
 | 
			
		||||
  if (color != 0) // transparent
 | 
			
		||||
    return color;
 | 
			
		||||
  
 | 
			
		||||
  depth = *(Visible_image_depth_buffer.Image+x+y*Main_image_width);
 | 
			
		||||
  return *(Main_backups->Pages->Image[depth] + x+y*Main_image_width);
 | 
			
		||||
  // return *(Main_screen+y*Main_image_width+x);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Pixel_in_current_screen      (word x,word y,byte color)
 | 
			
		||||
void Pixel_in_current_screen      (word x,word y,byte color,int with_preview)
 | 
			
		||||
{
 | 
			
		||||
	byte* dest=(x+y*Main_image_width+Main_screen);
 | 
			
		||||
	*dest=color;
 | 
			
		||||
    byte depth = *(Visible_image_depth_buffer.Image+x+y*Main_image_width);
 | 
			
		||||
    *(Main_backups->Pages->Image[Main_current_layer] + x+y*Main_image_width)=color;
 | 
			
		||||
    if ( depth <= Main_current_layer)
 | 
			
		||||
    {
 | 
			
		||||
      if (color == 0) // transparent
 | 
			
		||||
        // fetch pixel color from the topmost visible layer
 | 
			
		||||
        color=*(Main_backups->Pages->Image[depth] + x+y*Main_image_width);
 | 
			
		||||
      
 | 
			
		||||
      *(x+y*Main_image_width+Main_screen)=color;
 | 
			
		||||
      
 | 
			
		||||
      if (with_preview)
 | 
			
		||||
        Pixel_preview(x,y,color);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
byte Read_pixel_from_current_layer(word x,word y)
 | 
			
		||||
{
 | 
			
		||||
  return *((y)*Main_image_width+(x)+Main_backups->Pages->Image[Main_current_layer]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Replace_a_color(byte old_color, byte New_color)
 | 
			
		||||
@ -346,9 +370,9 @@ void Remap_general_lowlevel(byte * conversion_table,byte * buffer,short width,sh
 | 
			
		||||
 | 
			
		||||
void Copy_image_to_brush(short start_x,short start_y,short Brush_width,short Brush_height,word image_width)
 | 
			
		||||
{
 | 
			
		||||
	byte* src=start_y*image_width+start_x+Main_screen; //Adr départ image (ESI)
 | 
			
		||||
	byte* dest=Brush; //Adr dest brosse (EDI)
 | 
			
		||||
	int dx;
 | 
			
		||||
    byte* src=start_y*image_width+start_x+Main_backups->Pages->Image[Main_current_layer]; //Adr départ image (ESI)
 | 
			
		||||
    byte* dest=Brush; //Adr dest brosse (EDI)
 | 
			
		||||
    int dx;
 | 
			
		||||
 | 
			
		||||
	for (dx=Brush_height;dx!=0;dx--)
 | 
			
		||||
		//Pour chaque ligne
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3
									
								
								misc.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								misc.h
									
									
									
									
									
								
							@ -36,13 +36,14 @@ dword Round_div(dword numerator,dword divisor);
 | 
			
		||||
word Count_used_colors(dword * usage);
 | 
			
		||||
word Count_used_colors_area(dword* usage, word start_x, word start_y, word width, word height);
 | 
			
		||||
word Count_used_colors_screen_area(dword* usage, word start_x, word start_y, word width, word height);
 | 
			
		||||
void Pixel_in_current_screen      (word x,word y,byte color);
 | 
			
		||||
void Pixel_in_current_screen      (word x,word y,byte color,int with_preview);
 | 
			
		||||
void Pixel_in_brush             (word x,word y,byte color);
 | 
			
		||||
byte Read_pixel_from_current_screen  (word x,word y);
 | 
			
		||||
byte Read_pixel_from_spare_screen(word x,word y);
 | 
			
		||||
byte Read_pixel_from_backup_screen   (word x,word y);
 | 
			
		||||
byte Read_pixel_from_feedback_screen (word x,word y);
 | 
			
		||||
byte Read_pixel_from_brush         (word x,word y);
 | 
			
		||||
byte Read_pixel_from_current_layer(word x,word y);
 | 
			
		||||
 | 
			
		||||
void Ellipse_compute_limites(short horizontal_radius,short vertical_radius);
 | 
			
		||||
// Calcule les valeurs suivantes en fonction des deux paramètres:
 | 
			
		||||
 | 
			
		||||
@ -3004,7 +3004,8 @@ void Brush_0_5(void)
 | 
			
		||||
    Brush_offset_X=(Brush_offset_X/Snap_width)*Snap_width;
 | 
			
		||||
    Brush_offset_Y=(Brush_offset_Y/Snap_height)*Snap_height;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
  End_of_modification();
 | 
			
		||||
  End_of_modification();
 | 
			
		||||
  Return_to_draw_mode();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										24
									
								
								pages.h
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								pages.h
									
									
									
									
									
								
							@ -39,13 +39,12 @@ void Download_infos_page_main(T_Page * page);
 | 
			
		||||
void Upload_infos_page_main(T_Page * page);
 | 
			
		||||
 | 
			
		||||
// private
 | 
			
		||||
void Init_page(T_Page * page);
 | 
			
		||||
T_Page * New_page(void);
 | 
			
		||||
void Download_infos_page_spare(T_Page * page);
 | 
			
		||||
void Upload_infos_page_spare(T_Page * page);
 | 
			
		||||
void Download_infos_backup(T_List_of_pages * list);
 | 
			
		||||
void Free_a_page(T_Page * page);
 | 
			
		||||
void Clear_page(T_Page * page);
 | 
			
		||||
void Copy_S_page(T_Page * dest,T_Page * source);
 | 
			
		||||
int Size_of_a_page(T_Page * page);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -55,14 +54,11 @@ int Size_of_a_page(T_Page * page);
 | 
			
		||||
 | 
			
		||||
void Init_list_of_pages(T_List_of_pages * list);
 | 
			
		||||
// private
 | 
			
		||||
int Allocate_list_of_pages(T_List_of_pages * list,int size);
 | 
			
		||||
void Free_a_list_of_pages(T_List_of_pages * list);
 | 
			
		||||
int Size_of_a_list_of_pages(T_List_of_pages * list);
 | 
			
		||||
int Allocate_list_of_pages(T_List_of_pages * list);
 | 
			
		||||
void Backward_in_list_of_pages(T_List_of_pages * list);
 | 
			
		||||
void Advance_in_list_of_pages(T_List_of_pages * list);
 | 
			
		||||
int New_page_is_possible(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
 | 
			
		||||
void Free_last_page_of_list(T_List_of_pages * list);
 | 
			
		||||
void Create_new_page(T_Page * new_page,T_List_of_pages * current_list,T_List_of_pages * secondary_list);
 | 
			
		||||
int Create_new_page(T_Page * new_page,T_List_of_pages * current_list);
 | 
			
		||||
void Change_page_number_of_list(T_List_of_pages * list,int number);
 | 
			
		||||
void Free_page_of_a_list(T_List_of_pages * list);
 | 
			
		||||
 | 
			
		||||
@ -72,7 +68,7 @@ void Free_page_of_a_list(T_List_of_pages * list);
 | 
			
		||||
/// BACKUP HIGH-LEVEL FUNCTIONS
 | 
			
		||||
///
 | 
			
		||||
 | 
			
		||||
int Init_all_backup_lists(int size,int width,int height);
 | 
			
		||||
int Init_all_backup_lists(int width,int height);
 | 
			
		||||
void Set_number_of_backups(int nb_backups);
 | 
			
		||||
int Backup_with_new_dimensions(int upload,int width,int height);
 | 
			
		||||
int Backup_and_resize_the_spare(int width,int height);
 | 
			
		||||
@ -83,14 +79,4 @@ void Free_current_page(void); // 'Kill' button
 | 
			
		||||
void Exchange_main_and_spare(void);
 | 
			
		||||
void End_of_modification(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// BORROWING MEMORY FROM PAGE
 | 
			
		||||
///
 | 
			
		||||
 | 
			
		||||
void * Borrow_memory_from_page(int size);
 | 
			
		||||
// private
 | 
			
		||||
int Can_borrow_memory_from_page(int size);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										20
									
								
								struct.h
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								struct.h
									
									
									
									
									
								
							@ -319,9 +319,8 @@ typedef struct
 | 
			
		||||
// backup dans "graph.c".
 | 
			
		||||
 | 
			
		||||
/// This is the data for one step of Undo/Redo, for one image.
 | 
			
		||||
typedef struct
 | 
			
		||||
typedef struct T_Page
 | 
			
		||||
{
 | 
			
		||||
  byte *    Image;   ///< Pixel data for the image.
 | 
			
		||||
  int       Width;   ///< Image width in pixels.
 | 
			
		||||
  int       Height;  ///< Image height in pixels.
 | 
			
		||||
  T_Palette Palette; ///< Image palette.
 | 
			
		||||
@ -331,17 +330,27 @@ typedef struct
 | 
			
		||||
  char      File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file.
 | 
			
		||||
  char      Filename[MAX_PATH_CHARACTERS];      ///< Filename without directory.
 | 
			
		||||
  byte      File_format;                        ///< File format, in enum ::FILE_FORMATS
 | 
			
		||||
 | 
			
		||||
  struct T_Page *Next;
 | 
			
		||||
  struct T_Page *Prev;
 | 
			
		||||
  byte *    Image[NB_LAYERS];///< Pixel data for the image.
 | 
			
		||||
} T_Page;
 | 
			
		||||
 | 
			
		||||
/// Collection of undo/redo steps.
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  int      List_size;         ///< Number of ::T_Page in the vector "Pages".
 | 
			
		||||
  int      Nb_pages_allocated;///< Number of ::T_Page used so far in the vector "Pages".
 | 
			
		||||
  T_Page * Pages;             ///< Vector of Pages, each one being a undo/redo step.
 | 
			
		||||
  T_Page * Pages;             ///< Head of a linked list of pages, each one being a undo/redo step.
 | 
			
		||||
} T_List_of_pages;
 | 
			
		||||
 | 
			
		||||
/// A single image bitmap
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  int       Width;   ///< Image width in pixels.
 | 
			
		||||
  int       Height;  ///< Image height in pixels.
 | 
			
		||||
  //int       Users;   ///< Number of references.
 | 
			
		||||
  byte *    Image;   ///< Pixel data for the image.
 | 
			
		||||
} T_Image;
 | 
			
		||||
 | 
			
		||||
/// A single memorized brush from the Brush Container
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
@ -355,7 +364,6 @@ typedef struct
 | 
			
		||||
  byte Transp_color;
 | 
			
		||||
} T_Brush_template;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/// GUI skin data
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user