利用資料庫 Runtime 編輯ImageList |
|
scottliou
版主 發表:16 回覆:56 積分:47 註冊:2002-03-14 發送簡訊給我 |
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;~~~~~~~~~~~~~~~~ 有夢想最美......
------
~~~~~~~~~~~~~~~~ 有夢想最美...... |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |