1
/* Grafx2 - The Ultimate 256-color bitmap paint program
3
Copyright 2008 Yves Rizoud
4
Copyright 2008 Franck Charlet
5
Copyright 2007 Adrien Destugues
6
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
8
Grafx2 is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; version 2
13
Grafx2 is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
26
#include "sdlscreen.h"
33
void Pixel_triple (word x,word y,byte color)
34
/* Affiche un pixel de la color aux coords x;y � l'�cran */
36
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
37
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
38
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color;
39
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH)=color;
40
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 1)=color;
41
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 2)=color;
42
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH)=color;
43
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 1)=color;
44
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 2)=color;
47
byte Read_pixel_triple (word x,word y)
48
/* On retourne la couleur du pixel aux coords donn�es */
50
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
53
void Block_triple (word start_x,word start_y,word width,word height,byte color)
54
/* On affiche un rectangle de la couleur donn�e */
57
rectangle.x=start_x*ZOOMX;
58
rectangle.y=start_y*ZOOMY;
59
rectangle.w=width*ZOOMX;
60
rectangle.h=height*ZOOMY;
61
SDL_FillRect(Screen_SDL,&rectangle,color);
64
void Display_part_of_screen_triple (word width,word height,word image_width)
65
/* Afficher une partie de l'image telle quelle sur l'�cran */
67
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'�cran (dest)
68
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de d�part ds la source (src)
72
for(y=height;y!=0;y--)
75
// On fait une copie de la ligne
76
for (dy=width;dy>0;dy--)
78
*(dest+2)=*(dest+1)=*dest=*src;
82
// On double la ligne qu'on vient de copier
83
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
85
memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
87
// On passe � la ligne suivante
88
src+=image_width-width;
89
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
91
//Update_rect(0,0,width,height);
94
void Pixel_preview_normal_triple (word x,word y,byte color)
95
/* Affichage d'un pixel dans l'�cran, par rapport au d�calage de l'image
96
* dans l'�cran, en mode normal (pas en mode loupe)
97
* Note: si on modifie cette proc�dure, il faudra penser � faire �galement
98
* la modif dans la proc�dure Pixel_Preview_Loupe_SDL. */
100
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
101
Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color);
104
void Pixel_preview_magnifier_triple (word x,word y,byte color)
106
// Affiche le pixel dans la partie non zoom�e
107
Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color);
109
// Regarde si on doit aussi l'afficher dans la partie zoom�e
110
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
111
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
115
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
117
if (Menu_Y - y_zoom < Main_magnifier_factor)
118
// On ne doit dessiner qu'un morceau du pixel
119
// sinon on d�passe sur le menu
120
height = Menu_Y - y_zoom;
122
height = Main_magnifier_factor;
125
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
126
y_zoom, Main_magnifier_factor, height, color
131
void Horizontal_XOR_line_triple(word x_pos,word y_pos,word width)
133
//On calcule la valeur initiale de dest:
134
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
138
for (x=0;x<width*ZOOMX;x+=ZOOMX)
139
*(dest+x+2*VIDEO_LINE_WIDTH+2)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=~*(dest+x);
142
void Vertical_XOR_line_triple(word x_pos,word y_pos,word height)
145
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
146
for (i=height;i>0;i--)
148
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=~*dest;
149
dest+=VIDEO_LINE_WIDTH*ZOOMY;
153
void Display_brush_color_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
155
// dest = Position � l'�cran
156
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
157
// src = Position dans la brosse
158
byte* src = Brush + y_offset * brush_width + x_offset;
163
for(y = height;y > 0; y--)
166
for(x = width;x > 0; x--)
168
// On v�rifie que ce n'est pas la transparence
169
if(*src != transp_color)
171
*(dest+2*VIDEO_LINE_WIDTH+2) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+2) = *(dest+1) = *dest = *src;
179
// On passe � la ligne suivante
180
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
181
src = src + brush_width - width;
183
Update_rect(x_pos,y_pos,width,height);
186
void Display_brush_mono_triple(word x_pos, word y_pos,
187
word x_offset, word y_offset, word width, word height,
188
byte transp_color, byte color, word brush_width)
189
/* On affiche la brosse en monochrome */
191
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination �
193
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
197
for(y=height;y!=0;y--)
200
for(x=width;x!=0;x--)
203
if (*src!=transp_color)
204
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=color;
206
// On passe au pixel suivant
211
// On passe � la ligne suivante
212
src+=brush_width-width;
213
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
215
Update_rect(x_pos,y_pos,width,height);
218
void Clear_brush_triple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
220
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'�cran (dest)
221
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de d�part ds la source (src)
225
for(y=height;y!=0;y--)
228
for(x=width;x!=0;x--)
231
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*src;
233
// On passe au pixel suivant
238
// On passe � la ligne suivante
239
src+=image_width-width;
240
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
242
Update_rect(x_pos,y_pos,width,height);
245
// Affiche une brosse (arbitraire) � l'�cran
246
void Display_brush_triple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
248
// dest = Position � l'�cran
249
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
250
// src = Position dans la brosse
251
byte* src = brush + y_offset * brush_width + x_offset;
256
for(y = height;y > 0; y--)
259
for(x = width;x > 0; x--)
261
// On v�rifie que ce n'est pas la transparence
262
if(*src != transp_color)
264
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*src;
271
// On passe � la ligne suivante
272
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
273
src = src + brush_width - width;
277
void Remap_screen_triple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
279
// dest = coords a l'�cran
280
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
284
for(y=height;y>0;y--)
289
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=
290
conversion_table[*dest];
294
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
297
Update_rect(x_pos,y_pos,width,height);
300
void Display_line_on_screen_fast_triple(word x_pos,word y_pos,word width,byte * line)
301
/* On affiche toute une ligne de pixels telle quelle. */
302
/* Utilis�e si le buffer contient d�ja des pixel doubl�s. */
304
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
305
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
306
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
309
void Display_line_on_screen_triple(word x_pos,word y_pos,word width,byte * line)
310
/* On affiche une ligne de pixels en les doublant. */
314
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
317
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*line;
322
void Display_transparent_mono_line_on_screen_triple(
323
word x_pos, word y_pos, word width, byte* line,
324
byte transp_color, byte color)
325
// Affiche une ligne � l'�cran avec une couleur + transparence.
326
// Utilis� par les brosses en mode zoom
328
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
333
if (transp_color!=*line)
335
*(dest+2)=*(dest+1)=*dest=color;
337
line ++; // Pixel suivant
342
void Read_line_screen_triple(word x_pos,word y_pos,word width,byte * line)
344
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
347
void Display_part_of_screen_scaled_triple(
348
word width, // width non zoom�e
349
word height, // height zoom�e
350
word image_width,byte * buffer)
352
byte* src = Main_screen + Main_magnifier_offset_Y * image_width
353
+ Main_magnifier_offset_X;
354
int y = 0; // Ligne en cours de traitement
356
// Pour chaque ligne � zoomer
361
// On �clate la ligne
362
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
363
// On l'affiche Facteur fois, sur des lignes cons�cutives
364
x = Main_magnifier_factor/**ZOOMY*/;
367
// On affiche la ligne zoom�e
368
Display_line_on_screen_fast_triple(
369
Main_X_zoom, y, width*Main_magnifier_factor,
372
// On passe � la suivante
374
if(y==height/**ZOOMY*/)
376
Update_rect(Main_X_zoom,0,
377
width*Main_magnifier_factor,height);
384
// ATTENTION on n'arrive jamais ici !
387
// Affiche une partie de la brosse couleur zoom�e
388
void Display_brush_color_zoom_triple(word x_pos,word y_pos,
389
word x_offset,word y_offset,
390
word width, // width non zoom�e
391
word end_y_pos,byte transp_color,
392
word brush_width, // width r�elle de la brosse
395
byte* src = Brush+y_offset*brush_width + x_offset;
402
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
403
// On affiche facteur fois la ligne zoom�e
404
for(bx=Main_magnifier_factor;bx>0;bx--)
406
byte* line_src = buffer;
407
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
409
// Pour chaque pixel de la ligne
410
for(x = width*Main_magnifier_factor;x > 0;x--)
412
if(*line_src!=transp_color)
414
*(dest+2)=*(dest+1)=*dest = *line_src;
420
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
422
memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
431
// ATTENTION zone jamais atteinte
434
void Display_brush_mono_zoom_triple(word x_pos, word y_pos,
435
word x_offset, word y_offset,
436
word width, // width non zoom�e
438
byte transp_color, byte color,
439
word brush_width, // width r�elle de la brosse
444
byte* src = Brush + y_offset * brush_width + x_offset;
447
//Pour chaque ligne � zoomer :
451
// src = Ligne originale
452
// On �clate la ligne
453
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
455
// On affiche la ligne Facteur fois � l'�cran (sur des
456
// lignes cons�cutives)
457
bx = Main_magnifier_factor*ZOOMY;
459
// Pour chaque ligne �cran
462
// On affiche la ligne zoom�e
463
Display_transparent_mono_line_on_screen_triple(
464
x_pos, y, width * Main_magnifier_factor,
465
buffer, transp_color, color
467
// On passe � la ligne suivante
469
// On v�rifie qu'on est pas � la ligne finale
470
if(y == end_y_pos*ZOOMY)
472
Update_rect( x_pos, y_pos,
473
width * Main_magnifier_factor, end_y_pos - y_pos );
480
// Passage � la ligne suivante dans la brosse aussi
485
void Clear_brush_scaled_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
488
// En fait on va recopier l'image non zoom�e dans la partie zoom�e !
489
byte* src = Main_screen + y_offset * image_width + x_offset;
493
// Pour chaque ligne � zoomer
495
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
497
bx=Main_magnifier_factor;
502
Display_line_on_screen_fast_triple(x_pos,y,
503
width * Main_magnifier_factor,buffer);
509
Update_rect(x_pos,y_pos,
510
width*Main_magnifier_factor,end_y_pos-y_pos);
1
/* Grafx2 - The Ultimate 256-color bitmap paint program
3
Copyright 2008 Yves Rizoud
4
Copyright 2008 Franck Charlet
5
Copyright 2007 Adrien Destugues
6
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
8
Grafx2 is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; version 2
13
Grafx2 is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
26
#include "sdlscreen.h"
34
void Pixel_triple (word x,word y,byte color)
35
/* Affiche un pixel de la color aux coords x;y � l'�cran */
37
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
38
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
39
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color;
40
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH)=color;
41
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 1)=color;
42
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 2)=color;
43
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH)=color;
44
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 1)=color;
45
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 2)=color;
48
byte Read_pixel_triple (word x,word y)
49
/* On retourne la couleur du pixel aux coords donn�es */
51
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
54
void Block_triple (word start_x,word start_y,word width,word height,byte color)
55
/* On affiche un rectangle de la couleur donn�e */
58
rectangle.x=start_x*ZOOMX;
59
rectangle.y=start_y*ZOOMY;
60
rectangle.w=width*ZOOMX;
61
rectangle.h=height*ZOOMY;
62
SDL_FillRect(Screen_SDL,&rectangle,color);
65
void Display_part_of_screen_triple (word width,word height,word image_width)
66
/* Afficher une partie de l'image telle quelle sur l'�cran */
68
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'�cran (dest)
69
byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de d�part ds la source (src)
73
for(y=height;y!=0;y--)
76
// On fait une copie de la ligne
77
for (dy=width;dy>0;dy--)
79
*(dest+2)=*(dest+1)=*dest=*src;
83
// On double la ligne qu'on vient de copier
84
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
86
memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
88
// On passe � la ligne suivante
89
src+=image_width-width;
90
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
92
//Update_rect(0,0,width,height);
95
void Pixel_preview_normal_triple (word x,word y,byte color)
96
/* Affichage d'un pixel dans l'�cran, par rapport au d�calage de l'image
97
* dans l'�cran, en mode normal (pas en mode loupe)
98
* Note: si on modifie cette proc�dure, il faudra penser � faire �galement
99
* la modif dans la proc�dure Pixel_Preview_Loupe_SDL. */
101
// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
102
Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color);
105
void Pixel_preview_magnifier_triple (word x,word y,byte color)
107
// Affiche le pixel dans la partie non zoom�e
108
Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color);
110
// Regarde si on doit aussi l'afficher dans la partie zoom�e
111
if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
112
&& x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
116
int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
118
if (Menu_Y - y_zoom < Main_magnifier_factor)
119
// On ne doit dessiner qu'un morceau du pixel
120
// sinon on d�passe sur le menu
121
height = Menu_Y - y_zoom;
123
height = Main_magnifier_factor;
126
Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom,
127
y_zoom, Main_magnifier_factor, height, color
132
void Horizontal_XOR_line_triple(word x_pos,word y_pos,word width)
134
//On calcule la valeur initiale de dest:
135
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
139
for (x=0;x<width*ZOOMX;x+=ZOOMX)
140
*(dest+x+2*VIDEO_LINE_WIDTH+2)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=~*(dest+x);
143
void Vertical_XOR_line_triple(word x_pos,word y_pos,word height)
146
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
147
for (i=height;i>0;i--)
149
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=~*dest;
150
dest+=VIDEO_LINE_WIDTH*ZOOMY;
154
void Display_brush_color_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
156
// dest = Position � l'�cran
157
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
158
// src = Position dans la brosse
159
byte* src = Brush + y_offset * brush_width + x_offset;
164
for(y = height;y > 0; y--)
167
for(x = width;x > 0; x--)
169
// On v�rifie que ce n'est pas la transparence
170
if(*src != transp_color)
172
*(dest+2*VIDEO_LINE_WIDTH+2) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+2) = *(dest+1) = *dest = *src;
180
// On passe � la ligne suivante
181
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
182
src = src + brush_width - width;
184
Update_rect(x_pos,y_pos,width,height);
187
void Display_brush_mono_triple(word x_pos, word y_pos,
188
word x_offset, word y_offset, word width, word height,
189
byte transp_color, byte color, word brush_width)
190
/* On affiche la brosse en monochrome */
192
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination �
194
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
198
for(y=height;y!=0;y--)
201
for(x=width;x!=0;x--)
204
if (*src!=transp_color)
205
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=color;
207
// On passe au pixel suivant
212
// On passe � la ligne suivante
213
src+=brush_width-width;
214
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
216
Update_rect(x_pos,y_pos,width,height);
219
void Clear_brush_triple(word x_pos,word y_pos,__attribute__((unused)) word x_offset,__attribute__((unused)) word y_offset,word width,word height,__attribute__((unused))byte transp_color,word image_width)
221
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'�cran (dest)
222
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de d�part ds la source (src)
226
for(y=height;y!=0;y--)
229
for(x=width;x!=0;x--)
232
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*src;
234
// On passe au pixel suivant
239
// On passe � la ligne suivante
240
src+=image_width-width;
241
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
243
Update_rect(x_pos,y_pos,width,height);
246
// Affiche une brosse (arbitraire) � l'�cran
247
void Display_brush_triple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
249
// dest = Position � l'�cran
250
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
251
// src = Position dans la brosse
252
byte* src = brush + y_offset * brush_width + x_offset;
257
for(y = height;y > 0; y--)
260
for(x = width;x > 0; x--)
262
// On v�rifie que ce n'est pas la transparence
263
if(*src != transp_color)
265
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*src;
272
// On passe � la ligne suivante
273
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
274
src = src + brush_width - width;
278
void Remap_screen_triple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
280
// dest = coords a l'�cran
281
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
285
for(y=height;y>0;y--)
290
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=
291
conversion_table[*dest];
295
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
298
Update_rect(x_pos,y_pos,width,height);
301
void Display_line_on_screen_fast_triple(word x_pos,word y_pos,word width,byte * line)
302
/* On affiche toute une ligne de pixels telle quelle. */
303
/* Utilis�e si le buffer contient d�ja des pixel doubl�s. */
305
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
306
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
307
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
310
void Display_line_on_screen_triple(word x_pos,word y_pos,word width,byte * line)
311
/* On affiche une ligne de pixels en les doublant. */
315
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
318
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*line;
323
void Display_transparent_mono_line_on_screen_triple(
324
word x_pos, word y_pos, word width, byte* line,
325
byte transp_color, byte color)
326
// Affiche une ligne � l'�cran avec une couleur + transparence.
327
// Utilis� par les brosses en mode zoom
329
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
334
if (transp_color!=*line)
336
*(dest+2)=*(dest+1)=*dest=color;
338
line ++; // Pixel suivant
343
void Read_line_screen_triple(word x_pos,word y_pos,word width,byte * line)
345
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
348
void Display_part_of_screen_scaled_triple(
349
word width, // width non zoom�e
350
word height, // height zoom�e
351
word image_width,byte * buffer)
353
byte* src = Main_screen + Main_magnifier_offset_Y * image_width
354
+ Main_magnifier_offset_X;
355
int y = 0; // Ligne en cours de traitement
357
// Pour chaque ligne � zoomer
362
// On �clate la ligne
363
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
364
// On l'affiche Facteur fois, sur des lignes cons�cutives
365
x = Main_magnifier_factor/**ZOOMY*/;
368
// On affiche la ligne zoom�e
369
Display_line_on_screen_fast_triple(
370
Main_X_zoom, y, width*Main_magnifier_factor,
373
// On passe � la suivante
375
if(y==height/**ZOOMY*/)
377
Redraw_grid(Main_X_zoom,0,
378
width*Main_magnifier_factor,height);
379
Update_rect(Main_X_zoom,0,
380
width*Main_magnifier_factor,height);
387
// ATTENTION on n'arrive jamais ici !
390
// Affiche une partie de la brosse couleur zoom�e
391
void Display_brush_color_zoom_triple(word x_pos,word y_pos,
392
word x_offset,word y_offset,
393
word width, // width non zoom�e
394
word end_y_pos,byte transp_color,
395
word brush_width, // width r�elle de la brosse
398
byte* src = Brush+y_offset*brush_width + x_offset;
405
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
406
// On affiche facteur fois la ligne zoom�e
407
for(bx=Main_magnifier_factor;bx>0;bx--)
409
byte* line_src = buffer;
410
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
412
// Pour chaque pixel de la ligne
413
for(x = width*Main_magnifier_factor;x > 0;x--)
415
if(*line_src!=transp_color)
417
*(dest+2)=*(dest+1)=*dest = *line_src;
423
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
425
memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor);
434
// ATTENTION zone jamais atteinte
437
void Display_brush_mono_zoom_triple(word x_pos, word y_pos,
438
word x_offset, word y_offset,
439
word width, // width non zoom�e
441
byte transp_color, byte color,
442
word brush_width, // width r�elle de la brosse
447
byte* src = Brush + y_offset * brush_width + x_offset;
450
//Pour chaque ligne � zoomer :
454
// src = Ligne originale
455
// On �clate la ligne
456
Zoom_a_line(src,buffer,Main_magnifier_factor,width);
458
// On affiche la ligne Facteur fois � l'�cran (sur des
459
// lignes cons�cutives)
460
bx = Main_magnifier_factor*ZOOMY;
462
// Pour chaque ligne �cran
465
// On affiche la ligne zoom�e
466
Display_transparent_mono_line_on_screen_triple(
467
x_pos, y, width * Main_magnifier_factor,
468
buffer, transp_color, color
470
// On passe � la ligne suivante
472
// On v�rifie qu'on est pas � la ligne finale
473
if(y == end_y_pos*ZOOMY)
475
Redraw_grid( x_pos, y_pos,
476
width * Main_magnifier_factor, end_y_pos - y_pos );
477
Update_rect( x_pos, y_pos,
478
width * Main_magnifier_factor, end_y_pos - y_pos );
485
// Passage � la ligne suivante dans la brosse aussi
490
void Clear_brush_scaled_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,__attribute__((unused)) byte transp_color,word image_width,byte * buffer)
493
// En fait on va recopier l'image non zoom�e dans la partie zoom�e !
494
byte* src = Main_screen + y_offset * image_width + x_offset;
498
// Pour chaque ligne � zoomer
500
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
502
bx=Main_magnifier_factor;
507
Display_line_on_screen_fast_triple(x_pos,y,
508
width * Main_magnifier_factor,buffer);
514
Redraw_grid(x_pos,y_pos,
515
width*Main_magnifier_factor,end_y_pos-y_pos);
516
Update_rect(x_pos,y_pos,
517
width*Main_magnifier_factor,end_y_pos-y_pos);