H
Henry Wu
Hi, now that in .NET everything is on millimeter, I was wondering how
can one convert Pixel to Millimeter and any user's screen/monitor. I
saw the following code on how to convert pixel to millimeter. It's
done on pascal/delphi, but can be very easily read & converted to VB
..NET.
However my question is what is the difference between "real"
millimeters and "logical" millimeters?
The source of the code is in the following thread:
http://groups.google.com.ph/groups?...hl=en&ie=UTF-8&q=pixel+to+millimeters&spell=1
It's way back 1996, is it still correct & accurate?
Thanks,
Henry
======================================
procedure PixelsPerMM(canvas:TCanvas; var x,y:real);
procedure PixelsPerLogicalMM(canvas:TCanvas; var x,y:real);
implementation
procedure PixelsPerMM(canvas:TCanvas; var x,y:real);
var
h:HDC;
hres,vres,hsiz,vsiz:integer;
begin
h:=canvas.handle;
hres := GetDeviceCaps(h,HORZRES); {display width in pixels}
vres := GetDeviceCaps(h,VERTRES); {display height in pixels}
hsiz := GetDeviceCaps(h,HORZSIZE); {display width in mm}
vsiz := GetDeviceCaps(h,VERTSIZE); {display height in mm}
x := hres/hsiz;
y := vres/vsiz;
end;
procedure PixelsPerLogicalMM(canvas:TCanvas; var x,y:real);
var
h:hdc;
logpx,logpy:integer;
begin
h:=canvas.handle;
logpx := GetDeviceCaps(h,LOGPIXELSX); {pixels / logical x inch}
logpy := GetDeviceCaps(h,LOGPIXELSY); {pixels / logical y inch}
x := logpx / 25.4;
y := logpy / 25.4;
end;
end.
//ns
can one convert Pixel to Millimeter and any user's screen/monitor. I
saw the following code on how to convert pixel to millimeter. It's
done on pascal/delphi, but can be very easily read & converted to VB
..NET.
However my question is what is the difference between "real"
millimeters and "logical" millimeters?
The source of the code is in the following thread:
http://groups.google.com.ph/groups?...hl=en&ie=UTF-8&q=pixel+to+millimeters&spell=1
It's way back 1996, is it still correct & accurate?
Thanks,
Henry
======================================
procedure PixelsPerMM(canvas:TCanvas; var x,y:real);
procedure PixelsPerLogicalMM(canvas:TCanvas; var x,y:real);
implementation
procedure PixelsPerMM(canvas:TCanvas; var x,y:real);
var
h:HDC;
hres,vres,hsiz,vsiz:integer;
begin
h:=canvas.handle;
hres := GetDeviceCaps(h,HORZRES); {display width in pixels}
vres := GetDeviceCaps(h,VERTRES); {display height in pixels}
hsiz := GetDeviceCaps(h,HORZSIZE); {display width in mm}
vsiz := GetDeviceCaps(h,VERTSIZE); {display height in mm}
x := hres/hsiz;
y := vres/vsiz;
end;
procedure PixelsPerLogicalMM(canvas:TCanvas; var x,y:real);
var
h:hdc;
logpx,logpy:integer;
begin
h:=canvas.handle;
logpx := GetDeviceCaps(h,LOGPIXELSX); {pixels / logical x inch}
logpy := GetDeviceCaps(h,LOGPIXELSY); {pixels / logical y inch}
x := logpx / 25.4;
y := logpy / 25.4;
end;
end.
//ns