~ubuntu-branches/ubuntu/maverick/grafx2/maverick

« back to all changes in this revision

Viewing changes to pxtriple.c

  • Committer: Bazaar Package Importer
  • Author(s): Gürkan Sengün
  • Date: 2009-09-21 14:24:19 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090921142419-lhpqq102buior0ol
Tags: 2.1-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  Grafx2 - The Ultimate 256-color bitmap paint program
2
 
 
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)
7
 
 
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
11
 
    of the License.
12
 
 
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.
17
 
 
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/>
20
 
*/
21
 
 
22
 
#include <string.h>
23
 
#include <stdlib.h>
24
 
#include <SDL.h>
25
 
#include "global.h"
26
 
#include "sdlscreen.h"
27
 
#include "misc.h"
28
 
#include "pxtriple.h"
29
 
 
30
 
#define ZOOMX 3
31
 
#define ZOOMY 3
32
 
 
33
 
void Pixel_triple (word x,word y,byte color)
34
 
/* Affiche un pixel de la color aux coords x;y � l'�cran */
35
 
{
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;
45
 
}
46
 
 
47
 
byte Read_pixel_triple (word x,word y)
48
 
/* On retourne la couleur du pixel aux coords donn�es */
49
 
{
50
 
  return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
51
 
}
52
 
 
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 */
55
 
{
56
 
  SDL_Rect rectangle;
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);
62
 
}
63
 
 
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 */
66
 
{
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)
69
 
  int y;
70
 
  int dy;
71
 
 
72
 
  for(y=height;y!=0;y--)
73
 
  // Pour chaque ligne
74
 
  {
75
 
    // On fait une copie de la ligne
76
 
    for (dy=width;dy>0;dy--)
77
 
    {
78
 
      *(dest+2)=*(dest+1)=*dest=*src;
79
 
      src++;
80
 
      dest+=ZOOMX;
81
 
    }
82
 
    // On double la ligne qu'on vient de copier
83
 
    memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
84
 
    // On la triple
85
 
    memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
86
 
    
87
 
    // On passe � la ligne suivante
88
 
    src+=image_width-width;
89
 
    dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
90
 
  }
91
 
  //Update_rect(0,0,width,height);
92
 
}
93
 
 
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. */
99
 
{
100
 
//  if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
101
 
  Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color);
102
 
}
103
 
 
104
 
void Pixel_preview_magnifier_triple  (word x,word y,byte color)
105
 
{
106
 
  // Affiche le pixel dans la partie non zoom�e
107
 
  Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color);
108
 
  
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)
112
 
  {
113
 
    // On est dedans
114
 
    int height;
115
 
    int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
116
 
 
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;
121
 
    else
122
 
      height = Main_magnifier_factor;
123
 
 
124
 
    Block_triple(
125
 
      Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, 
126
 
      y_zoom, Main_magnifier_factor, height, color
127
 
      );
128
 
  }
129
 
}
130
 
 
131
 
void Horizontal_XOR_line_triple(word x_pos,word y_pos,word width)
132
 
{
133
 
  //On calcule la valeur initiale de dest:
134
 
  byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
135
 
 
136
 
  int x;
137
 
 
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);
140
 
}
141
 
 
142
 
void Vertical_XOR_line_triple(word x_pos,word y_pos,word height)
143
 
{
144
 
  int i;
145
 
  byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
146
 
  for (i=height;i>0;i--)
147
 
  {
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;
150
 
  }
151
 
}
152
 
 
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)
154
 
{
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;
159
 
 
160
 
  word x,y;
161
 
 
162
 
  // Pour chaque ligne
163
 
  for(y = height;y > 0; y--)
164
 
  {
165
 
    // Pour chaque pixel
166
 
    for(x = width;x > 0; x--)
167
 
    {
168
 
      // On v�rifie que ce n'est pas la transparence
169
 
      if(*src != transp_color)
170
 
      {
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;
172
 
      }
173
 
 
174
 
      // Pixel suivant
175
 
      src++;
176
 
      dest+=ZOOMX;
177
 
    }
178
 
 
179
 
    // On passe � la ligne suivante
180
 
    dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
181
 
    src = src + brush_width - width;
182
 
  }
183
 
  Update_rect(x_pos,y_pos,width,height);
184
 
}
185
 
 
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 */
190
 
{
191
 
  byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination � 
192
 
      // l'�cran
193
 
  byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds 
194
 
      // la brosse
195
 
  int x,y;
196
 
 
197
 
  for(y=height;y!=0;y--)
198
 
  //Pour chaque ligne
199
 
  {
200
 
    for(x=width;x!=0;x--)
201
 
    //Pour chaque pixel
202
 
    {
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;
205
 
 
206
 
      // On passe au pixel suivant
207
 
      src++;
208
 
      dest+=ZOOMX;
209
 
    }
210
 
 
211
 
    // On passe � la ligne suivante
212
 
    src+=brush_width-width;
213
 
    dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
214
 
  }
215
 
  Update_rect(x_pos,y_pos,width,height);
216
 
}
217
 
 
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)
219
 
{
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)
222
 
  int y;
223
 
  int x;
224
 
 
225
 
  for(y=height;y!=0;y--)
226
 
  // Pour chaque ligne
227
 
  {
228
 
    for(x=width;x!=0;x--)
229
 
    //Pour chaque pixel
230
 
    {
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;
232
 
 
233
 
      // On passe au pixel suivant
234
 
      src++;
235
 
      dest+=ZOOMX;
236
 
    }
237
 
 
238
 
    // On passe � la ligne suivante
239
 
    src+=image_width-width;
240
 
    dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
241
 
  }
242
 
  Update_rect(x_pos,y_pos,width,height);
243
 
}
244
 
 
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)
247
 
{
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;
252
 
  
253
 
  word x,y;
254
 
  
255
 
  // Pour chaque ligne
256
 
  for(y = height;y > 0; y--)
257
 
  {
258
 
    // Pour chaque pixel
259
 
    for(x = width;x > 0; x--)
260
 
    {
261
 
      // On v�rifie que ce n'est pas la transparence
262
 
      if(*src != transp_color)
263
 
      {
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;
265
 
      }
266
 
 
267
 
      // Pixel suivant
268
 
      src++; dest+=ZOOMX;
269
 
    }
270
 
 
271
 
    // On passe � la ligne suivante
272
 
    dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
273
 
    src = src + brush_width - width;
274
 
  }
275
 
}
276
 
 
277
 
void Remap_screen_triple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
278
 
{
279
 
  // dest = coords a l'�cran
280
 
  byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
281
 
  int x,y;
282
 
 
283
 
  // Pour chaque ligne
284
 
  for(y=height;y>0;y--)
285
 
  {
286
 
    // Pour chaque pixel
287
 
    for(x=width;x>0;x--)
288
 
    {
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];
291
 
      dest +=ZOOMX;
292
 
    }
293
 
 
294
 
    dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
295
 
  }
296
 
 
297
 
  Update_rect(x_pos,y_pos,width,height);
298
 
}
299
 
 
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. */
303
 
{
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);
307
 
}
308
 
 
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. */
311
 
{
312
 
  int x;
313
 
  byte *dest;
314
 
  dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
315
 
  for(x=width;x>0;x--)
316
 
  {
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;
318
 
    dest+=ZOOMX;
319
 
    line++;
320
 
  }
321
 
}
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
327
 
{
328
 
  byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
329
 
  int x;
330
 
  // Pour chaque pixel
331
 
  for(x=0;x<width;x++)
332
 
  {
333
 
    if (transp_color!=*line)
334
 
    {
335
 
      *(dest+2)=*(dest+1)=*dest=color;
336
 
    }
337
 
    line ++; // Pixel suivant
338
 
    dest+=ZOOMX;
339
 
  }
340
 
}
341
 
 
342
 
void Read_line_screen_triple(word x_pos,word y_pos,word width,byte * line)
343
 
{
344
 
  memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
345
 
}
346
 
 
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)
351
 
{
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
355
 
 
356
 
  // Pour chaque ligne � zoomer
357
 
  while(1)
358
 
  {
359
 
    int x;
360
 
    
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*/;
365
 
    // Pour chaque ligne
366
 
    do{
367
 
      // On affiche la ligne zoom�e
368
 
      Display_line_on_screen_fast_triple(
369
 
        Main_X_zoom, y, width*Main_magnifier_factor,
370
 
        buffer
371
 
      );
372
 
      // On passe � la suivante
373
 
      y++;
374
 
      if(y==height/**ZOOMY*/)
375
 
      {
376
 
        Update_rect(Main_X_zoom,0,
377
 
          width*Main_magnifier_factor,height);
378
 
        return;
379
 
      }
380
 
      x--;
381
 
    }while (x > 0);
382
 
    src += image_width;
383
 
  }
384
 
// ATTENTION on n'arrive jamais ici !
385
 
}
386
 
 
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
393
 
        byte * buffer)
394
 
{
395
 
  byte* src = Brush+y_offset*brush_width + x_offset;
396
 
  word y = y_pos;
397
 
  byte bx;
398
 
 
399
 
  // Pour chaque ligne
400
 
  while(1)
401
 
  {
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--)
405
 
    {
406
 
      byte* line_src = buffer;
407
 
      byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
408
 
      word x;
409
 
      // Pour chaque pixel de la ligne
410
 
      for(x = width*Main_magnifier_factor;x > 0;x--)
411
 
      {
412
 
        if(*line_src!=transp_color)
413
 
        {
414
 
          *(dest+2)=*(dest+1)=*dest = *line_src;
415
 
        }
416
 
        line_src++;
417
 
        dest+=ZOOMX;
418
 
      }
419
 
      // Double the line
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);
421
 
      // Triple the line
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);
423
 
      y++;
424
 
      if(y==end_y_pos)
425
 
      {
426
 
        return;
427
 
      }
428
 
    }
429
 
    src += brush_width;
430
 
  }
431
 
  // ATTENTION zone jamais atteinte
432
 
}
433
 
 
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 
437
 
        word end_y_pos,
438
 
        byte transp_color, byte color, 
439
 
        word brush_width, // width r�elle de la brosse
440
 
        byte * buffer
441
 
)
442
 
 
443
 
{
444
 
  byte* src = Brush + y_offset * brush_width + x_offset;
445
 
  int y=y_pos*ZOOMY;
446
 
 
447
 
  //Pour chaque ligne � zoomer :
448
 
  while(1)
449
 
  {
450
 
    int bx;
451
 
    // src = Ligne originale
452
 
    // On �clate la ligne
453
 
    Zoom_a_line(src,buffer,Main_magnifier_factor,width);
454
 
 
455
 
    // On affiche la ligne Facteur fois � l'�cran (sur des
456
 
    // lignes cons�cutives)
457
 
    bx = Main_magnifier_factor*ZOOMY;
458
 
 
459
 
    // Pour chaque ligne �cran
460
 
    do
461
 
    {
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
466
 
      );
467
 
      // On passe � la ligne suivante
468
 
      y++;
469
 
      // On v�rifie qu'on est pas � la ligne finale
470
 
      if(y == end_y_pos*ZOOMY)
471
 
      {
472
 
        Update_rect( x_pos, y_pos,
473
 
          width * Main_magnifier_factor, end_y_pos - y_pos );
474
 
        return;
475
 
      }
476
 
      bx --;
477
 
    }
478
 
    while (bx > 0);
479
 
    
480
 
    // Passage � la ligne suivante dans la brosse aussi
481
 
    src+=brush_width;
482
 
  }
483
 
}
484
 
 
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)
486
 
{
487
 
 
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;
490
 
  int y = y_pos;
491
 
  int bx;
492
 
 
493
 
  // Pour chaque ligne � zoomer
494
 
  while(1){
495
 
    Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
496
 
 
497
 
    bx=Main_magnifier_factor;
498
 
 
499
 
    // Pour chaque ligne
500
 
    do{
501
 
      // TODO a verifier
502
 
      Display_line_on_screen_fast_triple(x_pos,y,
503
 
        width * Main_magnifier_factor,buffer);
504
 
 
505
 
      // Ligne suivante
506
 
      y++;
507
 
      if(y==end_y_pos)
508
 
      {
509
 
        Update_rect(x_pos,y_pos,
510
 
          width*Main_magnifier_factor,end_y_pos-y_pos);
511
 
        return;
512
 
      }
513
 
      bx--;
514
 
    }while(bx!=0);
515
 
 
516
 
    src+= image_width;
517
 
  }
518
 
}
519
 
 
520
 
 
 
1
/*  Grafx2 - The Ultimate 256-color bitmap paint program
 
2
 
 
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)
 
7
 
 
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
 
11
    of the License.
 
12
 
 
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.
 
17
 
 
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/>
 
20
*/
 
21
 
 
22
#include <string.h>
 
23
#include <stdlib.h>
 
24
#include <SDL.h>
 
25
#include "global.h"
 
26
#include "sdlscreen.h"
 
27
#include "misc.h"
 
28
#include "graph.h"
 
29
#include "pxtriple.h"
 
30
 
 
31
#define ZOOMX 3
 
32
#define ZOOMY 3
 
33
 
 
34
void Pixel_triple (word x,word y,byte color)
 
35
/* Affiche un pixel de la color aux coords x;y � l'�cran */
 
36
{
 
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;
 
46
}
 
47
 
 
48
byte Read_pixel_triple (word x,word y)
 
49
/* On retourne la couleur du pixel aux coords donn�es */
 
50
{
 
51
  return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
 
52
}
 
53
 
 
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 */
 
56
{
 
57
  SDL_Rect rectangle;
 
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);
 
63
}
 
64
 
 
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 */
 
67
{
 
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)
 
70
  int y;
 
71
  int dy;
 
72
 
 
73
  for(y=height;y!=0;y--)
 
74
  // Pour chaque ligne
 
75
  {
 
76
    // On fait une copie de la ligne
 
77
    for (dy=width;dy>0;dy--)
 
78
    {
 
79
      *(dest+2)=*(dest+1)=*dest=*src;
 
80
      src++;
 
81
      dest+=ZOOMX;
 
82
    }
 
83
    // On double la ligne qu'on vient de copier
 
84
    memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
 
85
    // On la triple
 
86
    memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
 
87
    
 
88
    // On passe � la ligne suivante
 
89
    src+=image_width-width;
 
90
    dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
 
91
  }
 
92
  //Update_rect(0,0,width,height);
 
93
}
 
94
 
 
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. */
 
100
{
 
101
//  if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0)
 
102
  Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color);
 
103
}
 
104
 
 
105
void Pixel_preview_magnifier_triple  (word x,word y,byte color)
 
106
{
 
107
  // Affiche le pixel dans la partie non zoom�e
 
108
  Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color);
 
109
  
 
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)
 
113
  {
 
114
    // On est dedans
 
115
    int height;
 
116
    int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y);
 
117
 
 
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;
 
122
    else
 
123
      height = Main_magnifier_factor;
 
124
 
 
125
    Block_triple(
 
126
      Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, 
 
127
      y_zoom, Main_magnifier_factor, height, color
 
128
      );
 
129
  }
 
130
}
 
131
 
 
132
void Horizontal_XOR_line_triple(word x_pos,word y_pos,word width)
 
133
{
 
134
  //On calcule la valeur initiale de dest:
 
135
  byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
 
136
 
 
137
  int x;
 
138
 
 
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);
 
141
}
 
142
 
 
143
void Vertical_XOR_line_triple(word x_pos,word y_pos,word height)
 
144
{
 
145
  int i;
 
146
  byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
 
147
  for (i=height;i>0;i--)
 
148
  {
 
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;
 
151
  }
 
152
}
 
153
 
 
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)
 
155
{
 
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;
 
160
 
 
161
  word x,y;
 
162
 
 
163
  // Pour chaque ligne
 
164
  for(y = height;y > 0; y--)
 
165
  {
 
166
    // Pour chaque pixel
 
167
    for(x = width;x > 0; x--)
 
168
    {
 
169
      // On v�rifie que ce n'est pas la transparence
 
170
      if(*src != transp_color)
 
171
      {
 
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;
 
173
      }
 
174
 
 
175
      // Pixel suivant
 
176
      src++;
 
177
      dest+=ZOOMX;
 
178
    }
 
179
 
 
180
    // On passe � la ligne suivante
 
181
    dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
 
182
    src = src + brush_width - width;
 
183
  }
 
184
  Update_rect(x_pos,y_pos,width,height);
 
185
}
 
186
 
 
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 */
 
191
{
 
192
  byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination � 
 
193
      // l'�cran
 
194
  byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds 
 
195
      // la brosse
 
196
  int x,y;
 
197
 
 
198
  for(y=height;y!=0;y--)
 
199
  //Pour chaque ligne
 
200
  {
 
201
    for(x=width;x!=0;x--)
 
202
    //Pour chaque pixel
 
203
    {
 
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;
 
206
 
 
207
      // On passe au pixel suivant
 
208
      src++;
 
209
      dest+=ZOOMX;
 
210
    }
 
211
 
 
212
    // On passe � la ligne suivante
 
213
    src+=brush_width-width;
 
214
    dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
 
215
  }
 
216
  Update_rect(x_pos,y_pos,width,height);
 
217
}
 
218
 
 
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)
 
220
{
 
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)
 
223
  int y;
 
224
  int x;
 
225
 
 
226
  for(y=height;y!=0;y--)
 
227
  // Pour chaque ligne
 
228
  {
 
229
    for(x=width;x!=0;x--)
 
230
    //Pour chaque pixel
 
231
    {
 
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;
 
233
 
 
234
      // On passe au pixel suivant
 
235
      src++;
 
236
      dest+=ZOOMX;
 
237
    }
 
238
 
 
239
    // On passe � la ligne suivante
 
240
    src+=image_width-width;
 
241
    dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
 
242
  }
 
243
  Update_rect(x_pos,y_pos,width,height);
 
244
}
 
245
 
 
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)
 
248
{
 
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;
 
253
  
 
254
  word x,y;
 
255
  
 
256
  // Pour chaque ligne
 
257
  for(y = height;y > 0; y--)
 
258
  {
 
259
    // Pour chaque pixel
 
260
    for(x = width;x > 0; x--)
 
261
    {
 
262
      // On v�rifie que ce n'est pas la transparence
 
263
      if(*src != transp_color)
 
264
      {
 
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;
 
266
      }
 
267
 
 
268
      // Pixel suivant
 
269
      src++; dest+=ZOOMX;
 
270
    }
 
271
 
 
272
    // On passe � la ligne suivante
 
273
    dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
 
274
    src = src + brush_width - width;
 
275
  }
 
276
}
 
277
 
 
278
void Remap_screen_triple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
 
279
{
 
280
  // dest = coords a l'�cran
 
281
  byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
 
282
  int x,y;
 
283
 
 
284
  // Pour chaque ligne
 
285
  for(y=height;y>0;y--)
 
286
  {
 
287
    // Pour chaque pixel
 
288
    for(x=width;x>0;x--)
 
289
    {
 
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];
 
292
      dest +=ZOOMX;
 
293
    }
 
294
 
 
295
    dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
 
296
  }
 
297
 
 
298
  Update_rect(x_pos,y_pos,width,height);
 
299
}
 
300
 
 
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. */
 
304
{
 
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);
 
308
}
 
309
 
 
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. */
 
312
{
 
313
  int x;
 
314
  byte *dest;
 
315
  dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
 
316
  for(x=width;x>0;x--)
 
317
  {
 
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;
 
319
    dest+=ZOOMX;
 
320
    line++;
 
321
  }
 
322
}
 
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
 
328
{
 
329
  byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
 
330
  int x;
 
331
  // Pour chaque pixel
 
332
  for(x=0;x<width;x++)
 
333
  {
 
334
    if (transp_color!=*line)
 
335
    {
 
336
      *(dest+2)=*(dest+1)=*dest=color;
 
337
    }
 
338
    line ++; // Pixel suivant
 
339
    dest+=ZOOMX;
 
340
  }
 
341
}
 
342
 
 
343
void Read_line_screen_triple(word x_pos,word y_pos,word width,byte * line)
 
344
{
 
345
  memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
 
346
}
 
347
 
 
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)
 
352
{
 
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
 
356
 
 
357
  // Pour chaque ligne � zoomer
 
358
  while(1)
 
359
  {
 
360
    int x;
 
361
    
 
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*/;
 
366
    // Pour chaque ligne
 
367
    do{
 
368
      // On affiche la ligne zoom�e
 
369
      Display_line_on_screen_fast_triple(
 
370
        Main_X_zoom, y, width*Main_magnifier_factor,
 
371
        buffer
 
372
      );
 
373
      // On passe � la suivante
 
374
      y++;
 
375
      if(y==height/**ZOOMY*/)
 
376
      {
 
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);
 
381
        return;
 
382
      }
 
383
      x--;
 
384
    }while (x > 0);
 
385
    src += image_width;
 
386
  }
 
387
// ATTENTION on n'arrive jamais ici !
 
388
}
 
389
 
 
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
 
396
        byte * buffer)
 
397
{
 
398
  byte* src = Brush+y_offset*brush_width + x_offset;
 
399
  word y = y_pos;
 
400
  byte bx;
 
401
 
 
402
  // Pour chaque ligne
 
403
  while(1)
 
404
  {
 
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--)
 
408
    {
 
409
      byte* line_src = buffer;
 
410
      byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
 
411
      word x;
 
412
      // Pour chaque pixel de la ligne
 
413
      for(x = width*Main_magnifier_factor;x > 0;x--)
 
414
      {
 
415
        if(*line_src!=transp_color)
 
416
        {
 
417
          *(dest+2)=*(dest+1)=*dest = *line_src;
 
418
        }
 
419
        line_src++;
 
420
        dest+=ZOOMX;
 
421
      }
 
422
      // Double the line
 
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);
 
424
      // Triple the line
 
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);
 
426
      y++;
 
427
      if(y==end_y_pos)
 
428
      {
 
429
        return;
 
430
      }
 
431
    }
 
432
    src += brush_width;
 
433
  }
 
434
  // ATTENTION zone jamais atteinte
 
435
}
 
436
 
 
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 
 
440
        word end_y_pos,
 
441
        byte transp_color, byte color, 
 
442
        word brush_width, // width r�elle de la brosse
 
443
        byte * buffer
 
444
)
 
445
 
 
446
{
 
447
  byte* src = Brush + y_offset * brush_width + x_offset;
 
448
  int y=y_pos*ZOOMY;
 
449
 
 
450
  //Pour chaque ligne � zoomer :
 
451
  while(1)
 
452
  {
 
453
    int bx;
 
454
    // src = Ligne originale
 
455
    // On �clate la ligne
 
456
    Zoom_a_line(src,buffer,Main_magnifier_factor,width);
 
457
 
 
458
    // On affiche la ligne Facteur fois � l'�cran (sur des
 
459
    // lignes cons�cutives)
 
460
    bx = Main_magnifier_factor*ZOOMY;
 
461
 
 
462
    // Pour chaque ligne �cran
 
463
    do
 
464
    {
 
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
 
469
      );
 
470
      // On passe � la ligne suivante
 
471
      y++;
 
472
      // On v�rifie qu'on est pas � la ligne finale
 
473
      if(y == end_y_pos*ZOOMY)
 
474
      {
 
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 );
 
479
        return;
 
480
      }
 
481
      bx --;
 
482
    }
 
483
    while (bx > 0);
 
484
    
 
485
    // Passage � la ligne suivante dans la brosse aussi
 
486
    src+=brush_width;
 
487
  }
 
488
}
 
489
 
 
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)
 
491
{
 
492
 
 
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;
 
495
  int y = y_pos;
 
496
  int bx;
 
497
 
 
498
  // Pour chaque ligne � zoomer
 
499
  while(1){
 
500
    Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
 
501
 
 
502
    bx=Main_magnifier_factor;
 
503
 
 
504
    // Pour chaque ligne
 
505
    do{
 
506
      // TODO a verifier
 
507
      Display_line_on_screen_fast_triple(x_pos,y,
 
508
        width * Main_magnifier_factor,buffer);
 
509
 
 
510
      // Ligne suivante
 
511
      y++;
 
512
      if(y==end_y_pos)
 
513
      {
 
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);
 
518
        return;
 
519
      }
 
520
      bx--;
 
521
    }while(bx!=0);
 
522
 
 
523
    src+= image_width;
 
524
  }
 
525
}
 
526
 
 
527