Show thumbnail images of a folder lazarus / 31-LCL ---------------------------------------------------------------------- valter.home · 2020-10-05 12:51 Hello everybody, I was looking at the various components and trying TFileListBox, TShellTreeView, TShellListView. I'm looking for a component capable of showing a thumbnail of all the images contained in a folder. The purpose is to then drag the desired images into another container to create a sprite sheet from them. Is there anything inside Lazarus for viewing image previews or is it to manage via code? ---------------------------------------------------------------------- wp · 2020-10-05 14:32 There are thumbnail viewers in the JVCL library (install from Online- Package-Manager): JvThumbView and JvImagesViewer in the JvCustom package. ---------------------------------------------------------------------- valter.home · 2020-10-06 16:12 Thanks wp for the tip. In the meantime I have collected several info and written the following code for those who do not want to eventually use third-party components. It uses TShellTreeView and TShellListView. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMainForm.PreviewListImg;const  ImgPreviewSize = 64;var  Rct: TRect;  i, k, ImgPreviewHalfSize: integer;  ImgDraw: TBitmap;  ImgLoad: TPicture;  ImgPreviewList: TImageList;begin  ImgPreviewHalfSize := Round(ImgPreviewSize/2);  ImgPreviewList := TImageList.Create(Self);  ImgPreviewList.Width:=ImgPreviewSize;  ImgPreviewList.Height:=ImgPreviewSize;  ImgLoad := TPicture.Create;  ImgDraw := TBitmap.Create;  ImgDraw.SetSize(ImgPreviewSize,ImgPreviewSize);  for i := 0 to ShellListView1.Items.Count - 1 do  begin    try      ImgLoad.LoadFromFile(ShellTreeView1.Path + '\'+ShellListView1.Items[i].Caption);      ImgDraw.Canvas.Clear;      ImgDraw.Canvas.Brush.Color:=clNone;      ImgDraw.Canvas.FillRect(0,0,ImgPreviewSize,ImgPreviewSize);      if ((ImgLoad.Width <= ImgPreviewSize) and (ImgLoad.Height <= ImgPreviewSize)) then      begin        ImgDraw.Canvas.Draw(round(ImgPreviewHalfSize-(ImgLoad.Width/2)),                          round(ImgPreviewHalfSize-(ImgLoad.Height/2)),                          ImgLoad.Bitmap);        ImgPreviewList.Add(ImgDraw,NIL);        ShellListView1.Items[i].ImageIndex:=i;      end      else      begin      Rct.Left := 0;        Rct.Top := 0;        if ImgLoad.Width > ImgLoad.Height then        begin          Rct.Right := ImgPreviewSize;          Rct.Bottom := (ImgPreviewSize * ImgLoad.Height) div ImgLoad.Width;          k := round((ImgPreviewSize - Rct.bottom) /2);          Rct.Top:=k;          Rct.Bottom:=Rct.Bottom+k;          ImgDraw.Canvas.StretchDraw(Rct, ImgLoad.Graphic);        end        else if ImgLoad.Height > ImgLoad.Width then        begin          Rct.Bottom := ImgPreviewSize;          Rct.Right := (ImgPreviewSize * ImgLoad.Width) div ImgLoad.Height;          k := round((ImgPreviewSize - Rct.Right) / 2);          Rct.Left:=k;          Rct.Right:=Rct.Right+k;          ImgDraw.Canvas.StretchDraw(Rct, ImgLoad.Graphic);        end        else          ImgDraw.Canvas.StretchDraw(Rect(0,                                        0,                                          ImgPreviewSize,                                          ImgPreviewSize),                                          ImgLoad.Graphic);        ImgPreviewList.Add(ImgDraw,NIL);        ShellListView1.Items[i].ImageIndex:=i;      end;    except      // what you want    end;  end;  ShellListView1.LargeImages := ImgPreviewList;end; If the images are smaller than the ImgPreviewSize constant they are centered but left with their original size, if they are larger they are resized and centered. Obviously the code needs to be optimized but it can be used as a starting point. Anyone who likes to improve it is welcome. I am attaching an image showing the current result. ---------------------------------------------------------------------- valter.home · 2020-10-06 16:36 I notice now from the screenshot that the background of the previews is not transparent so the following lines of code fail: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i       ImgDraw.Canvas.Brush.Color:=clNone;      ImgDraw.Canvas.FillRect(0,0,ImgPreviewSize,ImgPreviewSize);  Actually the background is black by default, does anyone have any suggestions to make the preview images transparent?