線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1244
推到 Plurk!
推到 Facebook!

利用資料庫 Runtime 編輯ImageList

 
scottliou
版主


發表:16
回覆:56
積分:47
註冊:2002-03-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-04-04 17:33:40 IP:61.70.xxx.xxx 未訂閱
ImageListEditor.zip Source For D7 demo:if ExecuteImageListEditor(desImages) then
{-----------------------------------------------------------------------------}
//LoadFuncImage(desImages,DBImage1.Picture);
procedure LoadFuncImage(var imgList:TImageList; Picture:TPicture);
const
  AWidth=16;
  AHeight=16;
var
  cutBmp: TBitmap;
  I: Integer;
  Stream:TMemoryStream;
  Dest,Source:TRect;
begin
  Stream:=TMemoryStream.Create;
  ImgList.Clear;
  try
    cutBmp := TBitmap.Create;
    try
      Dest := Rect( 0, 0, AWidth, AHeight );
      cutBmp.Width:=AWidth;
      cutBmp.Height:=AHeight;
      for i:=0 to (Picture.Bitmap.Width div AWidth)-1 do
      begin
        Source:=Rect(i*AWidth,0,i*AWidth AWidth,AHeight);
        cutBmp.Canvas.CopyRect(Dest,Picture.Bitmap.Canvas,Source);
        ImgList.AddMasked(cutBmp,cutBmp.TransparentColor);
      end;
    finally
      cutBmp.Free;
    end;
  finally
    Stream.Free;
  end;
end;
{-----------------------------------------------------------------------------}
procedure SaveFuncImage(imgList:TImageList;fField:TField);
var
  Bitmap: TBitmap;
  TmpList: TImageList;
  I: Integer;
  Stream:TMemoryStream;
begin
  if ( ImgList.Count > 0 ) then
  begin
    TmpList := TImageList.CreateSize( ImgList.Width, ImgList.Height );
    TmpList.Assign(ImgList);
    Bitmap := TBitmap.Create;
    Stream:=TMemoryStream.Create;
    try
      with Bitmap do
      begin
        Width := TmpList.Width * TmpList.Count;
        Height := TmpList.Height;
        if TmpList.BkColor <> clNone then
          Canvas.Brush.Color := TmpList.BkColor
        else
          Canvas.Brush.Color := clWindow;
        Canvas.FillRect( Bounds( 0, 0, Width, Height ) );
        for I := 0 to TmpList.Count - 1 do
          TmpList.Draw( Canvas, TmpList.Width * I, 0, I );
        HandleType := bmDIB;
        if PixelFormat in [ pf15bit, pf16bit ] then
        try
          PixelFormat := pf24bit;
        except
        end;
      end;
      Bitmap.SaveToStream(Stream);
      fField.DataSet.Edit;
      TBlobField(fField).LoadFromStream(Stream);
      fField.DataSet.Post;
    finally
      Bitmap.Free;
      Stream.Free;
    end;
  end;
end;
~~~~~~~~~~~~~~~~ 有夢想最美......
------
~~~~~~~~~~~~~~~~
有夢想最美......
附加檔案:28130_ImageListEditor.zip
系統時間:2024-05-16 23:12:17
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!