Home > Back-end >  If copying from a tBitmap area one area to another tBitmap class?
If copying from a tBitmap area one area to another tBitmap class?

Time:09-27

 var 
Bmp1, bmp2: tBitmap


From the replication (intercept) areas to bmp1 bmp2,
Excuse me, how should do

CodePudding user response:

Bmp2. Canvas. CopyRect (the Rect (100100200200), bmp1. The Canvas, the Rect (0,0,100,100));

Copy from bmp1 0,0,100,100 region to bmp2 100100200200 area

CodePudding user response:

 
Procedure CropBitmap (InBitmap, OutBitMap: TBitmap; X, Y, W, H: Integer);
The begin
OutBitMap. PixelFormat:=InBitmap. PixelFormat;
OutBitMap. Width:=W;
OutBitMap. Height:=H;
BitBlt (OutBitMap. Canvas. Handle, 0, 0, W, H, InBitmap. Canvas. Handle, X, Y, SRCCOPY);
The end;
//use
Var
Bmp: TBitmap;
The begin
Bmp:=TBitmap. Create;
Try
CropBitmap (Image1. Picture. Bitmap Bmp, 10, 0, 150, 150);
.
The finally
Bmp. Free;
The end;
The end;

CodePudding user response:

StretchBlt can also zoom

Upstairs with JavaScript code can also for the code so neatly

CodePudding user response:

Can use the BitBlt function provided by the Windows

CodePudding user response:

Very busy

CodePudding user response:

Bmp2. Assign (bmp1);
Give bmp2 bmp1 values

CodePudding user response:

reference 1st floor pathletboy response:
bmp2. Canvas. The CopyRect (the Rect (100100200200), bmp1. The Canvas, the Rect (0,0,100,100));

Copy from bmp1 0,0,100,100 region to bmp2 100100200200 area

A simple, easy to

CodePudding user response:

This is my code:
1, read in Image1 will chart;
2, Image2, no PIC, and Image1 overlap; The mouse Image2 simulation for screenshots of the upper left point, right point location data: XX1, YY1, XX2, YY2;
3, the new resolution ComboBox1. ItemIndex
4, the new figure, as TempName ImagePath + + '. BMP 'save file name;
5, ChangeImageSize; Display screenshot

The code is as follows:
 procedure TSeleteImageFrm. Button2Click (Sender: TObject); 
Var MyRect NewRect: TRect;
Bmp, NewBmp: TBitmap;
S1, s2: string;
W, H, WW, WH: integer;
K, k1: double;
The begin
TempName:=Edit1. Text;//file name
If (XX2=0) or (YY2=0) then
The begin
XX1:=0;
YY1:=0;
XX2:=Image1. Picture. Graphic. Width;
YY2:=Image1. Picture. Graphic. Height;
The end;
Bmp:=TBitmap. Create;
NewBmp:=TBitmap. Create;
MyRect:=the Rect (XX1, YY1 XX2, YY2);
NewRect:=the Rect (0, 0, XX2 - XX1 YY2 - YY1);
Bmp. Width:=XX2 - XX1;
Bmp. Height:=YY2 - YY1;
Bmp. Canvas. CopyRect (NewRect, Image2. Canvas, MyRect);
Case ComboBox1. ItemIndex of
0: ChangeAnyPixels (Bmp, NewBmp, 100133);
1: ChangeAnyPixels (Bmp, NewBmp, 150200);
2: ChangeAnyPixels (Bmp, NewBmp, 200266);
3: ChangeAnyPixels (Bmp, NewBmp, 225300);
4: ChangeAnyPixels (Bmp, NewBmp, 300400);
The end;
NewBMP. SaveToFile (ImagePath + TempName + '. BMP ');
Image1. Picture. Assign (BMP);
Image2. Picture. Assign (BMP);
ChangeImageSize;
XX2:=0;
YY2:=0;
Bmp. Free;
NewBmp. Free;
The end;

CodePudding user response:

The code above are for reference only.

CodePudding user response:

1, the original image, use the mouse to choose regional

2, screenshots generated after new

CodePudding user response:

More warm-hearted man upstairs hehe I can't comment method also has a lot of kinds

CodePudding user response:

BMP. Canvas. CopyRect

CodePudding user response:

Canvas. CopyRect
API Bitbl etc
  • Related