Forum > Graphics

StrechDraw a .bmp File gets pixelated

(1/2) > >>

Weitentaaal:
Hello,

im currently creating a splash screen with this Code:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- procedure TfrmIntro.FormShow(Sender: TObject);var   temp: TBitmap;begin   temp:= TBitmap.Create;   temp.PixelFormat:= pf32bit;   temp.LoadFromFile(GetCurrentDir+'\pics\Intro\MyIntro.bmp');    Image1.Picture.Bitmap.SetSize(frmIntro.Width, frmIntro.Height);   Image1.Picture.Bitmap.Canvas.StretchDraw(Rect(0,0,frmIntro.Width, frmIntro.Height), temp);    temp.free;end;  
however the Pictures always get pixelated no matter which size the Picture or the Intro Form has. Does anyone have any Idea what i did wrong ?

thanks in advance

cdbc:
Hi
A quick fix for you, would be to fire up OPM and get TBGRABitmap et.al. installed and then use that as your background buffer:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- procedure TfrmIntro.FormShow(Sender: TObject);var   temp: TBGRABitmap;begin   temp:= TBGRABitmap.Create(GetCurrentDir+'\pics\Intro\MyIntro.bmp');   temp.PixelFormat:= pf32bit; // <- dunno about this one...   Image1.Stretch:= true;   Image1.Picture.Bitmap.SetSize(frmIntro.Width, frmIntro.Height);   Image1.Picture.Bitmap.Assign(temp);    temp.free;end;  Something like this.
edit: BGRBitmap also sports high quality resampling of pictures  :D
Regards Benny

TRon:

--- Quote from: Weitentaaal on May 05, 2023, 08:06:52 am ---however the Pictures always get pixelated no matter which size the Picture or the Intro Form has. Does anyone have any Idea what i did wrong ?

--- End quote ---
not without the lfm. I suspect that you have some (modified) properties for your TImage.

btw: Why so complicated ? Below some code that shows you which properties for TImage to set.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin  Image1.Align := alClient;  Image1.Stretch := True;  Image1.Picture.LoadFromFile('testpicture-5266x6583.bmp');end; Ofc. If you wish for the picture to load in the onshow event then that is ok.

The above works ok for me but the quality will degrade if your bmp is a lot smaller than the actual dimensions of the form. Using a bigger picture and down scaling it always provide a better result.

wp:
The splash screen is the first impression that new users have from your application - I would not make any compromise: display the unscaled image; if it is too large or too small find another one.

To display the unscaled image set the AutoSize of the TImage (which contains the splash image) to true, do not set its Stretch or Proportional to true. And also set the AutoSize of the splash form to true. This way you always have the best quality, and all sizes adjust themselves so that nothing is clipped or left uncovered.

TRon:
@wp: see picture  :)

btw why does the forum not accept webp image files ? Those are usually much smaller in size

Navigation

[0] Message Index

[#] Next page

Go to full version