放大镜
提示:这里可以添加技术概要
核心源码
uses
IniFiles;
const
KeywordSetup = ‘信息文件当前路径’;
KeywordDirectory = ‘目录’;
function IsPaletteDevice: BOOLEAN;
var
DeviceContext: hDC;
begin
//获取屏幕DC
DeviceContext := GetDC(0);
try
RESULT := GetDeviceCaps(DeviceContext, RASTERCAPS) and RC_PALETTE = RC_PALETTE
finally
// Give back the screen DC
ReleaseDC(0, DeviceContext)
end
end {是否设备调色板};
function GetPixelFormatString(const PixelFormat: TPixelFormat): string;
var
Format: string;
begin
case PixelFormat of
pfDevice: Format := ‘Device’;
pf1bit: Format := ‘1 bit’;
pf4bit: Format := ‘4 bit’;
pf8bit: Format := ‘8 bit’;
pf15bit: Format := ‘15 bit’;
pf16bit: Format := ‘16 bit’;
pf24bit: Format := ‘24 bit’;
pf32bit: Format := ‘32 bit’
else
Format := ‘Unknown’;
end;
RESULT := Format;
end {获得象素格式字符串};
function GetBitmapDimensionsString(const Bitmap: TBitmap): string;
begin
RESULT := IntToStr(Bitmap.Width) + ’ by ’ +
IntToStr(Bitmap.Height) + ’ pixels by ’ +
GetPixelFormatString(Bitmap.PixelFormat) + ’ color’;
end {获取位图的尺寸};
//===========================================================================
procedure TMagnifierForm.ShowMagnifier(const X, Y: INTEGER);
const
// 用额外的空间绘制环面
ExtraSpace = 8; // pixels
HalfExtraSpace = ExtraSpace div 2;
QuarterExtraSpace = ExtraSpace div 4;
var
AreaRadius: INTEGER;
CircularMask: TBitmap;
Magnification: INTEGER;
ModifiedBitmap: TBitmap;
xActual: INTEGER;
yActual: INTEGER;
begin
if CheckboxStretch.Checked
//拉伸则算出真实坐标
then begin
xActual := MulDiv(X, Bitmap.Width, BigImage.Width);
yActual := MulDiv(Y, Bitmap.Height, BigImage.Height)
end
else begin
xActual := X;
yActual := Y