用api函数StretchBlt 也可以 The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context. BOOL StretchBlt( HDC hdcDest, // handle to destination DC int nXOriginDest, // x-coord of destination upper-left corner int nYOriginDest, // y-coord of destination upper-left corner int nWidthDest, // width of destination rectangle int nHeightDest, // height of destination rectangle HDC hdcSrc, // handle to source DC int nXOriginSrc, // x-coord of source upper-left corner int nYOriginSrc, // y-coord of source upper-left corner int nWidthSrc, // width of source rectangle int nHeightSrc, // height of source rectangle DWORD dwRop // raster operation code );
MyBmp:=TBitmap.Create;
MyBmp.PixelFormat:=pf24Bit;
Mybmp.loadfromfile('c:\1.bmp');
Image1.Canvas.StretchDraw(Rect(0,0,300,200),MyBmp);
Finally
MyBmp.Free;
End;
300,200自己随便定
Var
Mybmp:Tbitmap;
就变为72象素/英寸了
不知道那错了
我的代码:Try
MyBmp:=TBitmap.Create;
MyBmp.PixelFormat:=pf24Bit;
Mybmp.loadfromfile('c:\1.bmp');
Image1.Canvas.StretchDraw(Rect(0,0,300,200),MyBmp);
Mybmp.width := 800;
MyBmp.Height := 600;
MyBmp.Savetofile('d:\2.bmp');
Finally
MyBmp.Free;
End;
错了,是
Image1.Canvas.StretchDraw(Rect(0,0,800,600),MyBmp
The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context. BOOL StretchBlt(
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int nHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
DWORD dwRop // raster operation code
);
image中的图片保存后分辨率还是72dpi
真晕
象素数/实际的英寸数,象素数可以得到,就是weight或height,
可是实际的英寸数怎么得到呢
photoshop中可以任意指定图片的宽度、高度(象素数),
并且可以任意指定分辨率,不知道怎么实现的,只是保存后的文件大小会受到影响
先谢了