Specific code is as follows:
Procedure Tfrm_cztz. Image1Click (Sender: TObject);//image1 controls click transfer into image
Var
Myjpeg: TJPEGImage;
Oldmybmp newmybmp: TBitmap;
, oldw, oldh neww, newh: integer;
OMemoStream: TMemoryStream;
The begin
Myjpeg:=TJPEGImage. Create;
Oldmybmp:=TBitmap. Create;
Newmybmp:=TBitmap. Create;
OMemoStream:=TMemoryStream. Create;
Neww:=200;
Newh:=200;
Try
With OpenDialog1 do
The begin
If the Execute then
The begin
CZTZ. Edit;//the data set editor status, or you can't give back data set assignment
Myjpeg. LoadFromFile (FileName);
//the following is according to the size of the new zoom
Oldmybmp. Assign (myjpeg);
Oldw:=oldmybmp. Width;
Oldh:=oldmybmp. Height;
Newmybmp. Width:=oldw * neww div oldw;
Newmybmp. Height:=oldh * newh div oldh;
SetStretchBltMode (newmybmp. Canvas. Handle, HalfTone);
StretchBlt (newmybmp. Canvas. Handle, 0, 0, neww, newh,
Oldmybmp. Canvas. Handle, 0, 0, oldw, oldh, SRCCOPY);
Myjpeg. Assign (newmybmp);
//quality according to the new image compression
Myjpeg.Com pressionQuality:=90;//to the quality of 90 is compressed
Myjpeg.Com press;
//show the processed images
Image1. Picture. Assign (myjpeg);
//is processed in the form of flow, avoid stored as files
Image1. Picture. Graphic. SaveToStream (oMemoStream);
OMemoStream. Position:=0;
TBlobField (CZTZ FieldbyName (' capture ')). LoadFromStream (oMemoStream);
CZTZ. Post;
Messagebox (getactivewindow (), 'image is saved! 'and' save ', mb_ok);
End
The else
exit;
end;
The finally
//release
Myjpeg. Free;
Oldmybmp. Free;
Newmybmp. Free;
OMemoStream. Free;
end;
end;
Procedure TFrm_cztz. ADOQueryAfterScroll (DataSet: TDataSet);//SQL display JPEG method
Var
OMemoStream: TMemoryStream;
PIC: tjpegimage;
The begin
OMemoStream:=TMemoryStream. Create;
PIC:=TJpegimage. Create;
Try
If not CZTZ. FieldByName (' screenshot). IsNull then
The begin
TBlobField (CZTZ FieldByName (' capture ')). SaveToStream (oMemoStream);
OMemoStream. Position:=0;
PIC. LoadFromStream (oMemoStream);
Image1. Picture. Graphic:=PIC;
End
The else
The begin
Image1. Picture:=nil;
end;
The finally
OMemoStream. Free;
PIC. Free;
end;
end;
CodePudding user response:
This is usually a flow in the process of handling errors,CodePudding user response: