New: Picture effects screen, resizes / mirrors / rotates image (Issue 73)
New: Distort brush (Issue 34) New: Pixel scaler "Triple" for 3x3 zoom (Issue 147) New: Pixel scaler "Quadruple" for 4x4 zoom (Issue 151) New: Pixel scaler "Wide2" for 4x2 zoom (Issue 148) New: Pixel scaler "Tall2" for 2x4 zoom (Issue 149) Fix of very old bug: Resizing the image didn't mark the image 'modified since last save' git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@763 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
103
pxwide.c
103
pxwide.c
@@ -29,27 +29,30 @@
|
||||
#include "misc.h"
|
||||
#include "pxwide.h"
|
||||
|
||||
#define ZOOMX 2
|
||||
#define ZOOMY 1
|
||||
|
||||
void Pixel_wide (word x,word y,byte color)
|
||||
/* Affiche un pixel de la color aux coords x;y à l'écran */
|
||||
{
|
||||
*(Screen_pixels + x * 2 + y * 2 * Screen_width)=color;
|
||||
*(Screen_pixels + x * 2 + y * 2 * Screen_width + 1)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
|
||||
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
|
||||
}
|
||||
|
||||
byte Read_pixel_wide (word x,word y)
|
||||
/* On retourne la couleur du pixel aux coords données */
|
||||
{
|
||||
return *( Screen_pixels + y * 2 * Screen_width + x * 2);
|
||||
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
|
||||
}
|
||||
|
||||
void Block_wide (word start_x,word start_y,word width,word height,byte color)
|
||||
/* On affiche un rectangle de la couleur donnée */
|
||||
{
|
||||
SDL_Rect rectangle;
|
||||
rectangle.x=start_x*2;
|
||||
rectangle.y=start_y;
|
||||
rectangle.w=width*2;
|
||||
rectangle.h=height;
|
||||
rectangle.x=start_x*ZOOMX;
|
||||
rectangle.y=start_y*ZOOMY;
|
||||
rectangle.w=width*ZOOMX;
|
||||
rectangle.h=height*ZOOMY;
|
||||
SDL_FillRect(Screen_SDL,&rectangle,color);
|
||||
}
|
||||
|
||||
@@ -69,12 +72,12 @@ void Display_part_of_screen_wide (word width,word height,word image_width)
|
||||
{
|
||||
*(dest+1)=*dest=*src;
|
||||
src++;
|
||||
dest+=2;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=(Screen_width - width)*2;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
//Update_rect(0,0,width,height);
|
||||
}
|
||||
@@ -119,32 +122,29 @@ void Pixel_preview_magnifier_wide (word x,word y,byte color)
|
||||
void Horizontal_XOR_line_wide(word x_pos,word y_pos,word width)
|
||||
{
|
||||
//On calcule la valeur initiale de dest:
|
||||
byte* dest=y_pos*2*Screen_width+x_pos*2+Screen_pixels;
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
|
||||
|
||||
int x;
|
||||
|
||||
for (x=0;x<width*2;x+=2)
|
||||
for (x=0;x<width*ZOOMX;x+=ZOOMX)
|
||||
*(dest+x+1)=*(dest+x)=~*(dest+x);
|
||||
}
|
||||
|
||||
void Vertical_XOR_line_wide(word x_pos,word y_pos,word height)
|
||||
{
|
||||
int i;
|
||||
byte color;
|
||||
byte *dest=Screen_pixels+x_pos*2+y_pos*Screen_width*2;
|
||||
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
|
||||
for (i=height;i>0;i--)
|
||||
{
|
||||
color=~*dest;
|
||||
*dest=color;
|
||||
*(dest+1)=color;
|
||||
dest+=Screen_width*2;
|
||||
*dest=*(dest+1)=~*dest;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY;
|
||||
}
|
||||
}
|
||||
|
||||
void Display_brush_color_wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * 2 * Screen_width + x_pos * 2;
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
|
||||
@@ -164,11 +164,11 @@ void Display_brush_color_wide(word x_pos,word y_pos,word x_offset,word y_offset,
|
||||
|
||||
// Pixel suivant
|
||||
src++;
|
||||
dest+=2;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + (Screen_width - width)*2;
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
@@ -179,7 +179,7 @@ void Display_brush_mono_wide(word x_pos, word y_pos,
|
||||
byte transp_color, byte color, word brush_width)
|
||||
/* On affiche la brosse en monochrome */
|
||||
{
|
||||
byte* dest=y_pos*2*Screen_width+x_pos*2+Screen_pixels; // dest = adr Destination à
|
||||
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à
|
||||
// l'écran
|
||||
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
|
||||
// la brosse
|
||||
@@ -196,19 +196,19 @@ void Display_brush_mono_wide(word x_pos, word y_pos,
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=2;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=brush_width-width;
|
||||
dest+=(Screen_width-width)*2;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
|
||||
void Clear_brush_wide(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)
|
||||
{
|
||||
byte* dest=Screen_pixels+x_pos*2+y_pos*2*Screen_width; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest)
|
||||
byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src)
|
||||
int y;
|
||||
int x;
|
||||
@@ -223,12 +223,12 @@ void Clear_brush_wide(word x_pos,word y_pos,__attribute__((unused)) word x_offse
|
||||
|
||||
// On passe au pixel suivant
|
||||
src++;
|
||||
dest+=2;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
src+=image_width-width;
|
||||
dest+=(Screen_width-width)*2;
|
||||
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
|
||||
}
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
}
|
||||
@@ -237,7 +237,7 @@ void Clear_brush_wide(word x_pos,word y_pos,__attribute__((unused)) word x_offse
|
||||
void Display_brush_wide(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
|
||||
{
|
||||
// dest = Position à l'écran
|
||||
byte* dest = Screen_pixels + y_pos * 2 * Screen_width + x_pos * 2;
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
// src = Position dans la brosse
|
||||
byte* src = brush + y_offset * brush_width + x_offset;
|
||||
|
||||
@@ -256,11 +256,11 @@ void Display_brush_wide(byte * brush, word x_pos,word y_pos,word x_offset,word y
|
||||
}
|
||||
|
||||
// Pixel suivant
|
||||
src++; dest+=2;
|
||||
src++; dest+=ZOOMX;
|
||||
}
|
||||
|
||||
// On passe à la ligne suivante
|
||||
dest = dest + (Screen_width - width)*2;
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
src = src + brush_width - width;
|
||||
}
|
||||
}
|
||||
@@ -268,7 +268,7 @@ void Display_brush_wide(byte * brush, word x_pos,word y_pos,word x_offset,word y
|
||||
void Remap_screen_wide(word x_pos,word y_pos,word width,word height,byte * conversion_table)
|
||||
{
|
||||
// dest = coords a l'écran
|
||||
byte* dest = Screen_pixels + y_pos * 2 * Screen_width + x_pos * 2;
|
||||
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
|
||||
int x,y;
|
||||
|
||||
// Pour chaque ligne
|
||||
@@ -278,10 +278,10 @@ void Remap_screen_wide(word x_pos,word y_pos,word width,word height,byte * conve
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*(dest+1) = *dest = conversion_table[*dest];
|
||||
dest +=2;
|
||||
dest +=ZOOMX;
|
||||
}
|
||||
|
||||
dest = dest + (Screen_width - width)*2;
|
||||
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
|
||||
}
|
||||
|
||||
Update_rect(x_pos,y_pos,width,height);
|
||||
@@ -291,7 +291,7 @@ void Display_line_on_screen_fast_wide(word x_pos,word y_pos,word width,byte * li
|
||||
/* On affiche toute une ligne de pixels telle quelle. */
|
||||
/* Utilisée si le buffer contient déja des pixel doublés. */
|
||||
{
|
||||
memcpy(Screen_pixels+x_pos*2+y_pos*2*Screen_width,line,width*2);
|
||||
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_line_on_screen_wide(word x_pos,word y_pos,word width,byte * line)
|
||||
@@ -299,13 +299,11 @@ void Display_line_on_screen_wide(word x_pos,word y_pos,word width,byte * line)
|
||||
{
|
||||
int x;
|
||||
byte *dest;
|
||||
dest=Screen_pixels+x_pos*2+y_pos*2*Screen_width;
|
||||
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
|
||||
for(x=width;x>0;x--)
|
||||
{
|
||||
*dest=*line;
|
||||
dest++;
|
||||
*dest=*line;
|
||||
dest++;
|
||||
*(dest+1)=*dest=*line;
|
||||
dest+=ZOOMX;
|
||||
line++;
|
||||
}
|
||||
}
|
||||
@@ -315,24 +313,23 @@ void Display_transparent_mono_line_on_screen_wide(
|
||||
// Affiche une ligne à l'écran avec une couleur + transparence.
|
||||
// Utilisé par les brosses en mode zoom
|
||||
{
|
||||
byte* dest = Screen_pixels+ y_pos*2 * Screen_width + x_pos*2;
|
||||
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
|
||||
int x;
|
||||
// Pour chaque pixel
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
if (transp_color!=*line)
|
||||
{
|
||||
*dest = color;
|
||||
*(dest+1) = color;
|
||||
*(dest+1)=*dest=color;
|
||||
}
|
||||
line ++; // Pixel suivant
|
||||
dest+=2;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
}
|
||||
|
||||
void Read_line_screen_wide(word x_pos,word y_pos,word width,byte * line)
|
||||
{
|
||||
memcpy(line,Screen_width * 2 * y_pos + x_pos * 2 + Screen_pixels,width*2);
|
||||
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
|
||||
}
|
||||
|
||||
void Display_part_of_screen_scaled_wide(
|
||||
@@ -350,7 +347,7 @@ void Display_part_of_screen_scaled_wide(
|
||||
int x;
|
||||
|
||||
// On éclate la ligne
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*2,width);
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
// On l'affiche Facteur fois, sur des lignes consécutives
|
||||
x = Main_magnifier_factor;
|
||||
// Pour chaque ligne
|
||||
@@ -378,8 +375,7 @@ void Display_part_of_screen_scaled_wide(
|
||||
void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color)
|
||||
{
|
||||
byte* src = line;
|
||||
byte* dest = Screen_pixels + y_pos * 2 * Screen_width + x_pos * 2;
|
||||
|
||||
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
|
||||
word x;
|
||||
|
||||
// Pour chaque pixel de la ligne
|
||||
@@ -387,11 +383,10 @@ void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,by
|
||||
{
|
||||
if(*src!=transp_color)
|
||||
{
|
||||
*dest = *src;
|
||||
*(dest+1) = *src;
|
||||
*(dest+1) = *dest = *src;
|
||||
}
|
||||
src++;
|
||||
dest+=2;
|
||||
dest+=ZOOMX;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,7 +409,7 @@ void Display_brush_color_zoom_wide(word x_pos,word y_pos,
|
||||
// On affiche facteur fois la ligne zoomée
|
||||
for(bx=Main_magnifier_factor;bx>0;bx--)
|
||||
{
|
||||
Display_transparent_line_on_screen_wide(x_pos,y,width*Main_magnifier_factor,buffer,transp_color);
|
||||
Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color);
|
||||
y++;
|
||||
if(y==end_y_pos)
|
||||
{
|
||||
@@ -437,7 +432,7 @@ void Display_brush_mono_zoom_wide(word x_pos, word y_pos,
|
||||
|
||||
{
|
||||
byte* src = Brush + y_offset * brush_width + x_offset;
|
||||
int y=y_pos;
|
||||
int y=y_pos*ZOOMY;
|
||||
|
||||
//Pour chaque ligne à zoomer :
|
||||
while(1)
|
||||
@@ -449,7 +444,7 @@ void Display_brush_mono_zoom_wide(word x_pos, word y_pos,
|
||||
|
||||
// On affiche la ligne Facteur fois à l'écran (sur des
|
||||
// lignes consécutives)
|
||||
bx = Main_magnifier_factor;
|
||||
bx = Main_magnifier_factor*ZOOMY;
|
||||
|
||||
// Pour chaque ligne écran
|
||||
do
|
||||
@@ -462,7 +457,7 @@ void Display_brush_mono_zoom_wide(word x_pos, word y_pos,
|
||||
// On passe à la ligne suivante
|
||||
y++;
|
||||
// On vérifie qu'on est pas à la ligne finale
|
||||
if(y == end_y_pos)
|
||||
if(y == end_y_pos*ZOOMY)
|
||||
{
|
||||
Update_rect( x_pos, y_pos,
|
||||
width * Main_magnifier_factor, end_y_pos - y_pos );
|
||||
@@ -486,7 +481,7 @@ void Clear_brush_scaled_wide(word x_pos,word y_pos,word x_offset,word y_offset,w
|
||||
|
||||
// Pour chaque ligne à zoomer
|
||||
while(1){
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*2,width);
|
||||
Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width);
|
||||
|
||||
bx=Main_magnifier_factor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user