More adjustments of layer preview : images less wide than a layer button are not zoomed more than normal size, and a max height is applied (Screen_height/4)

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1936 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2012-03-24 19:50:06 +00:00
parent c6479d22f6
commit cd5b3346b0
2 changed files with 14 additions and 10 deletions

View File

@ -13,7 +13,7 @@ $(OBJDIR)/buttons_effects.o: buttons_effects.c brush.h struct.h const.h buttons.
$(OBJDIR)/colorred.o: colorred.c colorred.h struct.h const.h $(OBJDIR)/colorred.o: colorred.c colorred.h struct.h const.h
$(OBJDIR)/engine.o: engine.c const.h struct.h global.h graph.h misc.h special.h \ $(OBJDIR)/engine.o: engine.c const.h struct.h global.h graph.h misc.h special.h \
buttons.h operatio.h shade.h errors.h sdlscreen.h windows.h brush.h \ buttons.h operatio.h shade.h errors.h sdlscreen.h windows.h brush.h \
input.h engine.h pages.h layers.h factory.h loadsave.h io.h input.h engine.h pages.h layers.h factory.h loadsave.h io.h pxsimple.h
$(OBJDIR)/factory.o: factory.c brush.h struct.h const.h buttons.h engine.h errors.h \ $(OBJDIR)/factory.o: factory.c brush.h struct.h const.h buttons.h engine.h errors.h \
filesel.h loadsave.h global.h graph.h io.h misc.h pages.h readline.h \ filesel.h loadsave.h global.h graph.h io.h misc.h pages.h readline.h \
sdlscreen.h windows.h palette.h input.h help.h realpath.h setup.h \ sdlscreen.h windows.h palette.h input.h help.h realpath.h setup.h \

View File

@ -43,7 +43,7 @@
#include "factory.h" #include "factory.h"
#include "loadsave.h" #include "loadsave.h"
#include "io.h" #include "io.h"
#include "pxsimple.h"
// we need this as global // we need this as global
@ -1429,9 +1429,13 @@ void Main_handler(void)
if (!preview_is_visible) if (!preview_is_visible)
{ {
previewW = Layer_button_width; previewW = Min(Main_image_width/Menu_factor_X,Layer_button_width);
previewH = previewW * Main_image_height / Main_image_width * Menu_factor_X / Menu_factor_Y; previewH = previewW * Main_image_height / Main_image_width * Menu_factor_X / Menu_factor_Y;
if (previewH * Menu_factor_Y > Menu_Y) previewH = Menu_Y / Menu_factor_Y; if (previewH > Screen_height/4)
{
previewH = Screen_height/4;
previewW = Main_image_width*previewH/Main_image_height*Menu_factor_Y/Menu_factor_X;
}
Open_popup((Buttons_Pool[BUTTON_LAYER_SELECT].X_offset + 2)*Menu_factor_X, Open_popup((Buttons_Pool[BUTTON_LAYER_SELECT].X_offset + 2)*Menu_factor_X,
Menu_Y - previewH * Menu_factor_Y, Buttons_Pool[BUTTON_LAYER_SELECT].Width, previewH); Menu_Y - previewH * Menu_factor_Y, Buttons_Pool[BUTTON_LAYER_SELECT].Width, previewH);
@ -1449,20 +1453,20 @@ void Main_handler(void)
//layer = Layer_under_mouse(); //layer = Layer_under_mouse();
for(layer = 0; layer < layercount; ++layer) for(layer = 0; layer < layercount; ++layer)
{ {
// Stop if the window is too small to show the int offset;
// Stop if the window is too small to show the
// layer button (ex: 320x200 can only display 12 layers) // layer button (ex: 320x200 can only display 12 layers)
if (layer*Layer_button_width+previewW > Window_width) if (layer*Layer_button_width+previewW > Window_width)
break; break;
offset=(Layer_button_width-previewW)/2;
for (y = 0; y < previewH*Pixel_height*Menu_factor_Y; y++) for (y = 0; y < previewH*Pixel_height*Menu_factor_Y; y++)
for (x = 0; x < previewW*Pixel_width*Menu_factor_X; x++) for (x = 0; x < previewW*Pixel_width*Menu_factor_X; x++)
{ {
int imgx = x * Main_image_width / previewW/Pixel_width/Menu_factor_X; int imgx = x * Main_image_width / previewW/Pixel_width/Menu_factor_X;
int imgy = y * Main_image_height / previewH/Pixel_height/Menu_factor_Y; int imgy = y * Main_image_height / previewH/Pixel_height/Menu_factor_Y;
// Use Pixel_simple() instead of Pixel_in_window() in order to get higher resolution // Use Pixel_simple() in order to get highest resolution
//Pixel_in_window(layer*Layer_button_width + x, y, *(Main_backups->Pages->Image[layer].Pixels Pixel_simple(x+((layer*Layer_button_width+offset)*Menu_factor_X+Window_pos_X)*Pixel_width, y+Window_pos_Y*Pixel_height, *(Main_backups->Pages->Image[layer].Pixels
// + imgx + imgy * Main_image_width));
Pixel_simple(x+(layer*Layer_button_width*Menu_factor_X+Window_pos_X)*Pixel_width, y+Window_pos_Y*Pixel_height, *(Main_backups->Pages->Image[layer].Pixels
+ imgx + imgy * Main_image_width)); + imgx + imgy * Main_image_width));
} }
} }