现在做的软件一个功能需对一张bmp图进行画图操作,窗体上需要显示原图和放大图,期望功能是画图操作在放大图上进行,如windows的画图板的放大功能,原图只是用来定位整体预览。原图的大小是410*1000(像素),放大图放大倍数差不多得8-16倍,最后文件以原图保存
现在的思路:
1.放大图只用来坐标定位,通过转换,在原图上进行画图操作,结束后再刷新放大图,刷新用的是StretchBlt。结果发现响应太慢,特别是在画图时鼠标拖动,因为此时一直得刷新放大图。有谁有好点的刷新思路吗?
2.通过SetMapMode、SetWindowExtEx 等函数坐标转换,结果发现放大后的效果与用StretchBlt放大的效果完全不一样,直线变得细致了。有没有方法让它和StretchBlt有一样的放大效果?
3.直接在放大图上画图操作,得重写画直线画圆画点等等函数...好烦...难道这是唯一的出路了么?
请达人指教啊,!!!
现在的思路:
1.放大图只用来坐标定位,通过转换,在原图上进行画图操作,结束后再刷新放大图,刷新用的是StretchBlt。结果发现响应太慢,特别是在画图时鼠标拖动,因为此时一直得刷新放大图。有谁有好点的刷新思路吗?
2.通过SetMapMode、SetWindowExtEx 等函数坐标转换,结果发现放大后的效果与用StretchBlt放大的效果完全不一样,直线变得细致了。有没有方法让它和StretchBlt有一样的放大效果?
3.直接在放大图上画图操作,得重写画直线画圆画点等等函数...好烦...难道这是唯一的出路了么?
请达人指教啊,!!!
var
ori,imagen: TBitmap;
dispositivo_o, dispositivo_d: HDC;
pepito: HBitmap;
begin
try
ori := Tbitmap.Create;
des := TBItmap.Create;
imagen := TBitmap.Create;
imagen.LoadFromFile(Source);
ori.handle := imagen.handle;
des.width := dWidth;
des.height := dHeight;
dispositivo_o := CreateCompatibleDC(0);
dispositivo_d := CreateCompatibleDC(0);
SelectObject(dispositivo_o, ori.handle);
pepito := SelectObject(dispositivo_d, des.handle);
SetStretchBltMode(dispositivo_d, STRETCH_HALFTONE);
StretchBlt(dispositivo_d, 0, 0, dWidth, dHeight, dispositivo_o, 0, 0, ori.width, ori.height, SRCCOPY);
SelectObject(dispositivo_d, pepito);
finally
ori.Free;
DeleteObject(pepito);
DeleteDC(dispositivo_o);
DeleteDC(dispositivo_d);
end;
end;
这是缩放图片的函数,画图就太容易了
var
des: TBitmap;
BMPx,BMPy,x,y,tx,ty,i,ColWidth,RowHeight,xx,yy,k:Integer;
Present:TDateTime;
str:String;
StarNo,s,ShadowWarp:Integer;
Year, Month, Day: Word;
c,ShadowColor:TColor;
bkRect : TRect;
begin
try
ShadowWarp:=SetIni.IniShadow;ShadowColor:=SetIni.IniShowDo; //阴影偏差、阴影字体底色
des := TBItmap.Create;
des.LoadFromFile(Target);
BMPx:=des.Width;
BMPy:=des.Height;
x:=BMPx div 3;tx:=x;
y:=10;ty:=10;
ColWidth:=5;RowHeight:=16;
des.Canvas.Font.Name:='宋体';
des.Canvas.Font.Size:=10;
des.Canvas.Pen.Style:=psClear;
des.Canvas.Brush.Style := bsClear;
for I := 7 downto 1 Do
begin
case i of
7:str:='日';
1:Str:='六';
2:Str:='五';
3:Str:='四';
4:Str:='三';
5:Str:='二';
6:Str:='一';
end;
tx:=y;
ty:=(BMPx-x-35)+(8-i)*(36+ColWidth);
des.Canvas.Font.Color:=ShadowColor;//$00E6E6E6
des.Canvas.TextOut(ty+ShadowWarp,tx+ShadowWarp,'星期'+str);这是我其中的一代代码,很容易的.