为了计算IMAGE中图形的坐标,需要知道图形的DPI,不知那位可给予指点???
解决方案 »
- ListBox.Items.Add问题请教
- Delphi怎样才能千千静听开着时发出声音
- 如果记录TReeView 的节点ID?
- 请大家推荐几个人气旺的sp论坛
- 急!请问:一运行,就出现System.pas文件,找不到的情况,但是明明有这个文件,求教各位高手!
- TRichEdit控件有不小的问题
- 如何用directshow或directdraw显示YUYV或RGBA数据???
- 数据库的readonly问题
- 麻烦大家看一下,这哪里错了?
- 请教高手:如何用sql语句实现将delphi的date类型数据插入到dbf表的date型字段中?
- 请教: 两处简单代码的差别?
- qreport的设计中我分组显示了查询的结果,并且想count每组的记录数量,怎么做啊?
是吗?
image.Picture.Bitmap.Height/Width是分辨率吗?分辨率好象应当是:
image.Picture.Bitmap.Height和image.Picture.Bitmap.width,您是否是这个意思?
图像分辨率的单位是ppi,dpi是用在打印机上的——打印机上一个dot并不等价于一个pixel。
对图像使用dpi是毫无意义的。
首先要理解BITMAPINFOHEADER这个东东,看这个就知道是什么了
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO, *PBITMAPINFO;
再看这个
typedef struct tagBITMAPINFOHEADER{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER, *PBITMAPINFOHEADER;
这里的biXPersPerMeter和biYPersPerMeter就是X、Y两轴的图像解析度!!
如果想要读出这个值就要看看TBitmap的源码,看看Borland怎么读Bitmap头的,然后写个小函数就可以了......
var
Bitmap, Mask: TBitmap;
x, y: integer;
Color: Longint;
R, G, B, Gr: byte;
ImageList: TImageList;
begin
Bitmap := TBitmap.Create;
Mask := TBitmap.Create; ImageList := TImageList.CreateSize(32, 32);
ImageList.AddIcon(Icon);
ImageList.GetBitmap(0, Bitmap);//以上三行实现Ico到Bitmap的转换 with Bitmap.Canvas do
for x := Cliprect.Left to Cliprect.Right do
for y := Cliprect.Top to Cliprect.Bottom do
begin
Color := ColorToRGB(Pixels[x, y]);
B := (Color and $FF0000) shr 16;
G := (Color and $FF00) shr 8;
R := (Color and $FF); B := B xor $FF;
G := G xor $FF;
R := R xor $FF; Pixels[x, y] := (B shl 16 ) or ( G shl 8) or R;
end;
Mask.Assign(Bitmap);
ImageList.Height := Bitmap.Height;
ImageList.Width := Bitmap.Width;
ImageList.Clear;
ImageList.Add(Bitmap, Mask);
ImageList.GetIcon(0, Icon);//以上实现Bitmap到Ico的转换 ImageList.Free;
Bitmap.Free;
Mask.Free;
end;
=====================
调用这个过程后图标失真...........
大伙教教我该如何改...................谢谢..
==============================================
那个x,y的最大值就是像素了吧...大伙顺便看看问题如何解决?