Ver Mensaje Individual
  #1  
Antiguo 16-05-2022
LACV LACV is offline
Miembro
 
Registrado: oct 2015
Posts: 80
Reputación: 9
LACV Va por buen camino
Exclamation Mostrar imagen en timage

Buen dia

necesito mostrar imagenes que estan guardadas en la DB en un Timage pero no lo e logrado, la verdad ando algo perdido, si me pueden ayudar se los agredeceria
tengo este codigo, es de recordar que es un proyecto en Friemonkey


Código Delphi [-]
procedure TS.reset;
var
  JpegStream: TMemoryStream;
  Jpeg, Bitmap: TBitmap;
  tmpPos, tmpLen: integer;
  pp: string;
  Data: string;
begin
  with QueryProductos Do
  begin
    Active := false;
    Active := true;

    Data := FieldByName('ImgProd').AsString;

    try
      tmpPos := Pos('B]>', Data);
      pp := Copy(Data, 5, tmpPos - 5);
      tmpLen := StrToInt(pp);
      Data := Copy(Data, tmpPos + 3, tmpLen);

      Bitmap := TBitmap.Create;
      try
        Jpeg := TBitmap.Create;
        try
          JpegStream := TMemoryStream.Create;
          try
            TIdDecoderMIME.DecodeStream(Data, JpegStream);
            JpegStream.Position := 0;
            Jpeg.LoadFromStream(JpegStream);
          finally
            JpegStream.Free;
          end;

          with Bitmap do
          begin
            SetSize(Jpeg.Width, Jpeg.Height);

            if Canvas.BeginScene then
              try
                Canvas.DrawBitmap(Jpeg,
{$IF RTLVersion >= 31} // 10.1 Berlin or higher
                  Jpeg.BoundsF,
{$ELSE}
                  TRectF.Create(0, 0, Jpeg.Width, Jpeg.Height),
{$IFEND}
                  TRectF.Create(0, 0, 200, 160), 1.0);
              finally
                Canvas.EndScene;
              end;
          end;
        finally
          Jpeg.Free;
        end;

        Image1.Bitmap.Assign(Bitmap);
        //image1.Bitmap.LoadFromFile(Bitmap);
      finally
        Bitmap.Free;
      end;
    except
      on E: Exception do
        //
    end;

  end;
end;

Última edición por LACV fecha: 16-05-2022 a las 19:35:02.
Responder Con Cita