8GDI•TImageDelphi•TCanvas•TCanvas•••••CanvasCanvasWin32(GDI)Win32GDIWindowsGDITCanvasTCanvasDelphi5Win32GDI8.1TImageDelphiTImageDelphi5TImage(.bmp)16Windows(.wmf)32(.emf)(.ico)TGraphicTImagePictureTPicture1.Win32(DDB)(DIB)Win32DDBDDBDDBDIBDDBDIBDDBDIBGDIDIBDDBDIBDIBDDB2.GDIGDIGDIWin32.wmf.emfWin16EMFEMF16WMF16WMFGDIEMFWMFDelphi5TMetaFile3.Win32.ico(.res)Windows32321616WindowsWindowsDelphiTListViewWin32TPictureTGraphicTPictureTBitMapTMetaFileTIconTGraphicTImage.PictureTImageMyImage.Picture.LoadFormFile('FileName.bmp');Win32MyImage.Picture.LoadFormFile('FileName.emf');Win32MyImage.Picture.LoadFormFile('FileName.ico');Delphi5TPictureJPEGMyImage.Picture.LoadFromFile('FileName.jpeg');8.2SaveToFile()MyImage.Picture.SaveToFile('FileName.bmp');TBitmapWin32TBitmap168TBitmapTBitmapTImageTMetafileTGraphic256TBitmapGetPaletle()TBitmapMyBitmap:=TBitMap.Create;MyBitmap.LoadFormFile('MyBMP.BMP');TBitmap.Assign()Bitmap1.Assign(Bitmap2);TBitmapCopyRect()varR1:Trect;beginwithR1dobeginTop:=0;Left:=0;Right:=BitMap2.Heightdiv2;Bottom:=BitMap2.Heightdiv2;end;Bitmap1.Canvas.CopyRect(ClientRect,BitMap2.Canvas,R1);end;TRectTCanvas.CopyRect()TRectTRect=recordCaseIntegerof0:(Left,Top,Right,Bottom:Integer);1:(TopLeft,BottomRight:TPoint);end;PaintCopyRect()CopyRect()Assign()VCLStretchDraw()Canvas.StretchDraw(R1,MyBitmap);TCanvas8.3TCanvasTFormTGraphicCanvas8GDI169TCanvas8.3.1TPenCanvas.PenTpenColorWidthStyleModeColorDelphi5clRedclYellowDelphi5Win32clActiveCaptionclHightTextWin32Canvas.Pen.Color:=clBlue;CanvasPen.Color=TColor(RGB(Random(255),Random(255),Random(255)));RGB()TcolorWin32Win32RGB(RGB)Win32TColor255RGB()1600RGB(000)RGB(255255255)RGB(25500)RGB(02550)RGB(00255)RGB()TColorVCLGraphics.pasWindowsclBlueclBtnFaceTColor000102DelphiTColortypeColorToRGB()Win32(clWindow)RGBDelphi5Style8-1Pen.Style8-1psClearpsDotpsDashpsInsideFrampsDashDotpsSolidpsDashDotDot:Canvas.Pen.Style:=psDashDot;8-1Canvas.Brush.ColorclRedCanvas.Brush.StylebsClear1708-1Pen.Width()1216GDIWin32Windows95/98WindowsNT/2000GDIWin32Win32(ROP)Pen.ModeROP8-2Win32168-2Win32Pen.Color(S)(D)pmBlack0pmWhite1pmNOPDpmNOTnotDpmCopyColorSpmNotCopynotSpmMergePenNotSornotDpmMaskPenNotSandnotDpmMergeNotPennotSorDpmMaskNotPennotSandDpmMergeSorDpmNotMergepmMergenot(SorD)pmMaskSandDpmNotMaskpmMergenot(SandD)pmXorSXORDpmNotXorpmXornot(SXORD)Pen.modepmCopyColorPen.ColorPen.ColorPen.ColorclBlackPen.mode8GDI171pmNot8-28-2pmNotMerge8-1CD8-18-2CD8-11728GDI1738-1Canvas()SetPenDefaults()Canvas.PenClearCanvas()CanvasClearCanvas()FilRect()TRect8-1mmiStylesClick(),TCanvas.MoveTo()TCanvas.LineTo()mmiPenColorsClick()RGB()TPen.ColorRGB()02558-3mmiPenModeClick()pmNot8-21748-3mmiPenColorsClick()8.3.2TCanvas.PixelsTCanvas.PixelsTColorCanvas.Pixels[0,0];Canvas.Pixels{clientwidth,clientheight}PixelsGetPixel()SetPixel()Microsoft24RGB24RGBRGBTBitmap.ScanlinePixels8.3.3TBrush1.TBrushTPenCanvasTBrushColorStyleBitmapColorStyleBitmapStyle8bsSolidbsClearbsHorizontalbsVerticalbsFDiagonalbsBDiagonalbsCrossbsDiagCrossclWhitebsSolid2.TBrush8-2TBrushCD8GDI1758-2TBrush1768GDI177ClearCanvas()ClearCanvas()TCavasProcrdureTMainForm.ClearCanvas(ACanvas:TCanvas);VarR:Trect;begin//withACanvasdobeginBrush.Style:=bsSolid;Brush.Color:=clWhite;GrtWindowRect(Handlr,R);R.TopLeft:=ScreenToClient(R.TopLeft);R.BottonRight:=ScreenToClient(R.BottomRight);FillRect(R);end;end;mmiPatternsClick()8-4mmiBitmapPattern1Click()mmiBitmapPattern2Click()TCanvas.BrushTBitmapTBrush.Style178TBrush.Bitmapnil8-58-6mmiBitmapPattern1Click()mmiBitmapPattern2Click()8-48-5mmiBitmapPattern1Click()8-6mmiBitmapPattern2Click()8GDI179Windows88WindowsNT88CanvasCanvasTImageImage1.Canvas.Brush.Bitmap:=SomeBitmap;tryImage1.Canvas.Rectangle(0,0,Imagel.Width,Imagel.Height);finallyImagel.Canvas.Brush.Bitmap:=nil;end;8.3.4Canvas.FontWin32Font.ColorDelphi5Canvas.Font.Color:=clRed;NameWindowsNewTimeRomanCanvas.Font.Name:='NewTimesRoman';Canvas.Font.SizeCanvas.Font.Style8-38-3fsfsItalicfsUnderLinefsStrickOutCanvas.FontStyle:=[fsBold,fsItalic];TFontDialogWin32TMemo.FontifFontDialogl.ExecutethenMemo1.Font.Assign(FontDialog1.Font);TFontDialogFontCanvas.Font.Assing(FontDialog1.Font);TBitmapTBrushTIconTMetaFileTPenTPictureAssign()MyBrush1:=MyBrush2;Assign()TFontForm1.Font:=Form2.Font;180TForm.FontAssign()TFontAssign()TFontDialogCanvas.Font.Name:=Font.Dialog1.Font.Name;Canvas.Font.Size:=Font.Dialog.Font.Size;8.3.5CopyModeTcanvas.CopyModeCopyModecmSrcCopycmSrcInvertXORCopyModeCopyModeCopyMode8-78-7TComboBoxCopyModeCopy8-88-9CopyModecmSrcAndcmSrcInvertimgFromImageimgToImage8-7CopyMode8-8cmSrcAnd8GDI1818-9cmSrcIMvert8-3CD8-31828GDI183TImageimgFromImageimgToImageCopyimgFromImagecbCopyModeimgToImage8.3.6TcanvasTCanvas.ClipRectClipRectClipRectClipRectClipRectCanvasTCanvas.HandleTCanvasTCanvas.PenPosXYTCanvasMoveTo()LineTo()PolyLine()TextOut()8.4TCanvasTCanvasGDITCanvas8.4.1TCanvasTCanvas.MoveTo()Canvas.Pen184Canvas.MoveTo(0,0);TCanvas.LineTo()MoveTo()LineTo()Canvas.MoveTo(0,0);Canvas.LineTo(ClientWidth,ClientHeight);TCanvas.PenMoveTo()LineTo()Delphi()XWindowsDelphiMoveTo(0,0)8.4.2TCanva