Witam. Chcę zrobić coś takiego: do filelistboxa mam załadowane obrazki o rozszerzeniach png, jpeg i gif, następnie, gdy zostanie wybrana opcja obrotu obrazka chcę aby odczytało mi rozszerzenie pliku i o ile to możliwe przekonwertowało go na bmp, dalej to już było by z górki :) poniżej procedura do obracania i moje próby konwertowania do bmp...
obrót:
Procedure TurnImage(var Src : TImage; CCW : integer);
var
x, y : integer;
Dst : TImage;
BitM : TBitmap;
begin
Dst := TImage.Create(nil);
Dst.Width:= Src.Picture.Height;
Dst.Height:= Src.Picture.Width;
if Src.Picture.Bitmap = nil then
BitM := TBitmap.Create;
BitM.Assign(TBitmap(Src.Picture.Graphic));
Src.Picture.Bitmap.Assign(BitM);
if CCW = 0 then // w prawo
for x:= 0 to Src.Picture.Height do
for y:= 0 to Src.Picture.Width do
Dst.Canvas.Pixels[x,y]:= Src.canvas.pixels[y, Src.Picture.Height-x-1];
if CCW = 1 then // w lewo
for x:= 0 to Src.Picture.Height do
for y:= 0 to Src.Picture.Width do
Dst.Canvas.Pixels[x,y]:= Src.Canvas.Pixels[Src.Picture.Width-y-1, x];
Src.Picture.Bitmap := Dst.Picture.Bitmap;
Dst.Free;
end;
moje wypociny:
procedure TForm1.Obrto90wprawo1Click(Sender: TObject);
var
jpg:TJPEGimage;
bmp:TBitmap;
begin
if filelistbox1.FileName='.jpg' then
begin
jpg:=TJPEGimage.Create;
bmp:=TBitmap.Create;
jpg.LoadFromFile(filelistbox1.FileName);
bmp.Assign(jpg);
image1.Picture.Bitmap:=bmp;
turnimage(image1,0);
end;
end;