Fábio Matte Posted February 5, 2021 Share Posted February 5, 2021 When I upload an image using TUnimFileUpload, TUnimImage behaves perfectly by applying the "Proportional" Property correctly, however when I upload the same image using TUnimFileUploadButton, this property does not do what it should do, which is to display the image of proportionally. How should I make this property behave correctly using TUnimFileUploadButton? Link to comment Share on other sites More sharing options...
Sherzod Posted February 5, 2021 Share Posted February 5, 2021 Hello, Can you please make a simple testcase for both to see the issue? Link to comment Share on other sites More sharing options...
Fábio Matte Posted February 8, 2021 Author Share Posted February 8, 2021 Solved with a conversion function. function ConverteMiniatura(Imagem: TGraphic; W, H: Integer; vTransparente : Boolean; Tipo: TGraphicClass = nil): TGraphic; var B : TBitmap; jpg : TJPEGImage; LogFont : TLogFont; aFont : TFont; Rect1 : TRect; sText : string; lAltura, lLargura, lEsquerda, lDireita : Integer; vIncRect : Integer; ww, hh : Integer; newH, newW : Integer; X, Y : integer; Imagem2 : TGraphic; begin B := TBitmap.Create; try if imgW < imgH then begin newH := W; newW := H; end; if imgW > imgH then begin newH := H; newW := W; end; H := newH; W := newW; B.Height := H; B.Width := W; B.Transparent := vTransparente; B.Canvas.StretchDraw(Rect(0, 0, W, H), Imagem ); if Tipo = nil then Result := TGraphic(Imagem.ClassType.Create) else begin Result := Tipo.Create; Result.Assign(B); end; Try Jpg := TJPEGImage.Create; Jpg.Assign(B); Jpg.CompressionQuality := 100; jpg.Compress; Jpg.SaveToFile( PatchArquivosCliente + 'thumbmail\' + IntToStr( myChapa ) + '.jpg' ); Finally Jpg.Free; End; finally B.Free; end; end; Link to comment Share on other sites More sharing options...
Recommended Posts