Jump to content

Problem with TUnimImage "Proportional" property [ Solved ]


Fábio Matte

Recommended Posts

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

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

  • Fábio Matte changed the title to Problem with TUnimImage "Proportional" property [ Solved ]
×
×
  • Create New...