1. I will use this for putting images in to PicShow:
- Code: Select all
procedure CopyGraphicToBitmap(Graphic: TGraphic; Bitmap: TBitmap;
MaxWidth, MaxHeight: Integer; ShrinkOnly: Boolean);
var
Width, Height: Integer;
begin
Width := Graphic.Width;
Height := Graphic.Height;
if not ShrinkOnly or (Width > MaxWidth) or (Height > MaxHeight) then
begin
if (MaxWidth / Width) < (MaxHeight / Height) then
begin
Height := MulDiv(Height, MaxWidth, Width);
Width := MaxWidth;
end
else
begin
Width := MulDiv(Width, MaxHeight, Height);
Height := MaxHeight;
end;
end;
Bitmap.Width := Width;
Bitmap.Height := Height;
with Bitmap.Canvas do StretchDraw(ClipRect, Graphic);
end;
But there is one issue. When image is loaded with this and window is small:
- Code: Select all
CopyGraphicToBitmap(P.Graphic, PicShow.Picture.Bitmap,
PicShow.Width, PicShow.Height, True);
Problem is when user maximizes the window then user gets that small image what is resized with this CopyGraphic...
If I change that to this:
- Code: Select all
CopyGraphicToBitmap(P.Graphic, PicShow.Picture.Bitmap,
Screen.Width, Screen.Height, True);
Same problem occurs if user has multiple monitors and resolutions are different.
2. Without that CopyGraphicToBitmap PicShow cannot handly huge images ex. 3800 x 2500. This size is problem ex. in Win98, XP can handle bigger images, but still problem is there.
So is there any way to load and display huge images so that they are fitted to screen?
- Marko