Use an int to compute the zoom to cursor instead of a short for better precision and more security (using a short could lead to overflows on big screens/pictures). However there is still a drift, if you zoom in/out a lot of times without moving the mouse you'll notice that the zoom window moves to the down/right corner of the picture. Might be because of the truncate done on the fixed point calculations, but i'm not sure...
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1136 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
5e3f845176
commit
a725f0035e
12
windows.c
12
windows.c
@ -1535,8 +1535,8 @@ void Compute_magnifier_data(void)
|
||||
/// Changes magnifier factor and updates everything needed
|
||||
void Change_magnifier_factor(byte factor_index)
|
||||
{
|
||||
short center_x;
|
||||
short center_y;
|
||||
int center_x;
|
||||
int center_y;
|
||||
|
||||
// Values that need to be computed before switching to the new zoom factor
|
||||
if (Cursor_in_menu)
|
||||
@ -1545,8 +1545,8 @@ void Change_magnifier_factor(byte factor_index)
|
||||
center_y=Main_magnifier_offset_Y+(Main_magnifier_height>>1);
|
||||
} else {
|
||||
// Zoom to cursor
|
||||
center_x = (Paintbrush_X - Main_magnifier_offset_X) * 255 / Main_magnifier_width;
|
||||
center_y = (Paintbrush_Y - Main_magnifier_offset_Y) * 255 / Main_magnifier_height;
|
||||
center_x = (Paintbrush_X - Main_magnifier_offset_X) * 65536 / Main_magnifier_width;
|
||||
center_y = (Paintbrush_Y - Main_magnifier_offset_Y) * 65536 / Main_magnifier_height;
|
||||
}
|
||||
|
||||
Main_magnifier_factor=ZOOM_FACTOR[factor_index];
|
||||
@ -1561,8 +1561,8 @@ void Change_magnifier_factor(byte factor_index)
|
||||
Main_magnifier_offset_X=center_x-(Main_magnifier_width>>1);
|
||||
Main_magnifier_offset_Y=center_y-(Main_magnifier_height>>1);
|
||||
} else {
|
||||
Main_magnifier_offset_X = Paintbrush_X - center_x * Main_magnifier_width / 255 ;
|
||||
Main_magnifier_offset_Y = Paintbrush_Y - center_y * Main_magnifier_height / 255 ;
|
||||
Main_magnifier_offset_X = Paintbrush_X - center_x * Main_magnifier_width / 65536 ;
|
||||
Main_magnifier_offset_Y = Paintbrush_Y - center_y * Main_magnifier_height / 65536 ;
|
||||
}
|
||||
// Correction en cas de débordement de l'image
|
||||
if (Main_magnifier_offset_X+Main_magnifier_width>Main_image_width)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user