做图片体现

运行效果图源码

procedure TfrmMain.GridDrawCell(Sender: TObject; ACol, ARow: Integer;  Rect: TRect; State: TGridDrawState);var  ACanvas:TCanvas;  R:TRect;  Bmp:TBitMap;begin  ACanvas := Grid.Canvas;  ACanvas.Brush.Color := clGreen;  Bmp := GetPicture(ACol,ARow);  if Bmp <> nil then  begin    R := Rect;    R.Left := R.Left + 5;    R.Top  := R.Top  + 5;    R.Right := R.Right - 5;    R.Bottom := R.Bottom - 5;    ACanvas.StretchDraw;  end;end;function TfrmMain.GetPicture(ACol, ARow: Integer): TBitMap;var  Index:Integer;begin  Result := nil;  Index := ARow * Grid.ColCount + ACol;  if Index <= PicList.Count - 1 then    Result := TBitMap(PicList.Items[Index]);end;procedure TfrmMain.FormCreate(Sender: TObject);var  Bmp:TBitMap;  Index:Integer;  AFileName:string;begin  PicList := TList.Create();  for Index := 1 to 18 do  begin    AFileName := format(ExtractFilePath(Application.ExeName) + 'Image%d.bmp',[Index]);    Bmp := TBitMap.Create();    Bmp.LoadFromFile(AFileName);    PicLIst.Add;  end;end;

图片 1

本文由华夏彩票发布于编程应用,转载请注明出处:做图片体现

您可能还会对下面的文章感兴趣: