//抄书的type TMdDbGrid =class (TDbGrid) private FLinesPerRow:Integer; procedure SetLinesPerRow (Value:Integer); protected procedure DrawColumnCell(const Rect:TRect;DataCol:Integer; Column:TColumn;State:TGridDrawState);override ; procedure LayoutChanged;override ; public constructor Create (AOwner:TComponent);override ; published property LinesPerRow:Integer read FLinesPerRow write SetLinesPerRow default 1; end; procedure TMdDbGrid.SetLinesPerRow(Value:Integer); begin if Value <>FLinesPerRow then begin FLinesPerRow := Value; LayoutChanged; end; end;procedure TMdDbGrid.Create(AOwner: TComponent); override; begin inherited; FLinesPreRow := 1; end;procedure TMdDbGrid.LayOutChanged; var PixelsPerRow,PixelsTitle,I:Integer; begin inherited LayOutChanged; Canvas.Font :=Font; PixelsPerRow :=Canvas.TextHeight(‘Wg ’)+3; if dgRowLines in Options then Inc (PixelsPerRow,GridLineWidth); Canvas.Font :=TitleFont; PixelsTitle :=Canvas.TextHeight(‘Wg ’)+4; if dgRowLines in Options then Inc (PixelsTitle,GridLineWidth); //算行数 RowCount :=1 +(Height -PixelsTitle)div (PixelsPerRow *FLinesPerRow); //每行的高度 DefaultRowHeight :=PixelsPerRow * FLinesPerRow; RowHeights [0 ] :=PixelsTitle; for I :=1 to RowCount -1 do RowHeights [I ] :=PixelsPerRow * FLinesPerRow; end;procedure TMdDbGrid.DrawColumnCell (const Rect:TRect;DataCol:Integer; Column:TColumn;State:TGridDrawState); var Bmp:TBitmap; OutRect:TRect; begin if FLinesPerRow =1 then inherited DrawColumnCell(Rect,DataCol,Column,State) else begin Canvas.FillRect (Rect); OutRect :=Rect; InflateRect (OutRect,-2,-2); if Column.Field is TGraphicField then begin Bmp :=TBitmap.Create; try Bmp.Assign (Column.Field); Canvas.StretchDraw (OutRect,Bmp); finally Bmp.Free; end; end else if Column.Field is TMemoField then begin DrawText (Canvas.Handle,PChar (Column.Field.AsString), Length (Column.Field.AsString),OutRect,dt_WordBreak or dt_NoPrefix) end else DrawText (Canvas.Handle,PChar (Column.Field.DisplayText), Length (Column.Field.DisplayText),OutRect, dt_vcenter or dt_SingleLine or dt_NoPrefix); end; end ;
TMdDbGrid =class (TDbGrid)
private
FLinesPerRow:Integer;
procedure SetLinesPerRow (Value:Integer);
protected
procedure DrawColumnCell(const Rect:TRect;DataCol:Integer;
Column:TColumn;State:TGridDrawState);override ;
procedure LayoutChanged;override ;
public
constructor Create (AOwner:TComponent);override ;
published
property LinesPerRow:Integer read FLinesPerRow write SetLinesPerRow default 1;
end;
procedure TMdDbGrid.SetLinesPerRow(Value:Integer);
begin
if Value <>FLinesPerRow then
begin
FLinesPerRow := Value;
LayoutChanged;
end;
end;procedure TMdDbGrid.Create(AOwner: TComponent); override;
begin
inherited;
FLinesPreRow := 1;
end;procedure TMdDbGrid.LayOutChanged;
var
PixelsPerRow,PixelsTitle,I:Integer;
begin
inherited LayOutChanged;
Canvas.Font :=Font;
PixelsPerRow :=Canvas.TextHeight(‘Wg ’)+3;
if dgRowLines in Options then
Inc (PixelsPerRow,GridLineWidth);
Canvas.Font :=TitleFont;
PixelsTitle :=Canvas.TextHeight(‘Wg ’)+4;
if dgRowLines in Options then
Inc (PixelsTitle,GridLineWidth);
//算行数
RowCount :=1 +(Height -PixelsTitle)div (PixelsPerRow *FLinesPerRow);
//每行的高度
DefaultRowHeight :=PixelsPerRow * FLinesPerRow;
RowHeights [0 ] :=PixelsTitle;
for I :=1 to RowCount -1 do
RowHeights [I ] :=PixelsPerRow * FLinesPerRow;
end;procedure TMdDbGrid.DrawColumnCell (const Rect:TRect;DataCol:Integer;
Column:TColumn;State:TGridDrawState);
var
Bmp:TBitmap;
OutRect:TRect;
begin
if FLinesPerRow =1 then
inherited DrawColumnCell(Rect,DataCol,Column,State)
else
begin
Canvas.FillRect (Rect);
OutRect :=Rect;
InflateRect (OutRect,-2,-2);
if Column.Field is TGraphicField then
begin
Bmp :=TBitmap.Create;
try
Bmp.Assign (Column.Field);
Canvas.StretchDraw (OutRect,Bmp);
finally
Bmp.Free;
end;
end
else if Column.Field is TMemoField then
begin
DrawText (Canvas.Handle,PChar (Column.Field.AsString),
Length (Column.Field.AsString),OutRect,dt_WordBreak or dt_NoPrefix)
end
else
DrawText (Canvas.Handle,PChar (Column.Field.DisplayText),
Length (Column.Field.DisplayText),OutRect,
dt_vcenter or dt_SingleLine or dt_NoPrefix);
end;
end ;
然后通过dbimage或者其它的dbjpeg(待高手开发)将数据读出谢谢各位关心的朋友
将adotable的cursorlocation设置为:clUseServer
将:cachesize设置为10
比较一下速度.
我想你是看了李维的书了:)
10*150K=?
1000*150K=?
cursorlocation一定要设置为clUseServer
不要对表做遍历操作. <切记>
如果150k/图,速度应在2秒之内.
最好使用Oracle数据库,它可以有效的管理40T的数据。
我也是做GIS的,你叫个朋友吧!我帮你找找控件,我有一些。你用MO吗?
然后Timage对jpg什么的都自动支持了!
对于Gif还要装第三方控件的!
我们以前的做法是这样的:把图片写入IMAGE类型字段中,要用的时候把他先转为JPG文件,然后用IMAGE控件就可以了呀。写入、读出都可以用TBLOBFIELD。
如果一定要这么存的话 字段格式要改成BLOB 字段 然后将数据以二进制流的形式存入