[delphi] jak pociac obrazek

0

hi - jak pociąć obrazek zaladowany na 8 rownych kwadratow lub prostokatow i kazdy z nich umiescic w osobnym image np czesc1:=image1 czesc2:=image2 itp ?? kto mi moze pomoc?

0

Copies part of an image from another canvas into the canvas.

Delphi syntax:

procedure CopyRect(const Dest: TRect; Canvas: TCanvas; const Source: TRect);

C++ syntax:

void __fastcall CopyRect(const TRect &Dest, TCanvas* Canvas, const TRect &Source);

Description

Use CopyRect to transfer part of the image on another canvas to the image of the TCanvas object. Dest specifies the rectangle on the canvas where the source image will be copied. The Canvas parameter specifies the canvas with the source image. Source specifies a rectangle bounding the portion of the source canvas that will be copied.

The portion of the source canvas is copied using the mode specified by CopyMode.

image1.Canvas.CopyRect(Gdzie,zczego,kwadratskad);

zalozmy ze mamy bmp : tbitmap; czyli bitmape w pamieci
to kopjuje z image1 do bmp wycinek CUT_RECT (czyli ten wycinek ktory ty chcesz)
cut_rect := rect(lewo,gora,prawo,dol);
bmp.Canvas.CopyRect(rect(0,0,bmp.width,bmp.height),image1.canvas,cut_rect);

pętla po X*Y kwadratow w bmp
zdefiniuj jeszcze wielkość kratki
kx,ky: integer;

for x:=0 to 3 do
for y:=0 to 5 do begin
cut_rect := rect(xkx,kyy,xkx+kx,yky+ky);
bmp.Canvas.CopyRect(rect(0,0,bmp.width,bmp.height),image1.canvas,cut_rect);
bmp.savetofile();
end;

niew iem czy to dobrze zadziala ale cos takiego

0

eh dzony dobra robota - tylko wiesz ja zabardzo nie moge siepolapac w tym przykladzie moglbys podac jakis konkretny przyklad ?

0

a kod na koncu posta to nie jest przyklad?

0

nie znajduje cut_rect - dodalem x,y :integer ale nadal blad

procedure TForm1.Button1Click(Sender: TObject);
var
kx,ky: integer;
x,y: integer;
 begin

for x:=0 to 3 do
for y:=0 to 5 do begin
cut_rect := rect(x*kx,ky*y,x*kx+kx,y*ky+ky);
bmp.Canvas.CopyRect(rect(0,0,bmp.width,bmp.height),image1.canvas,cut_rect);
bmp.savetofile();
end;

??

1 użytkowników online, w tym zalogowanych: 0, gości: 1