AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi Pixel in Millimiter umrechnen mit dieser Funktion ?
Thema durchsuchen
Ansicht
Themen-Optionen

Pixel in Millimiter umrechnen mit dieser Funktion ?

Ein Thema von thomas2009 · begonnen am 4. Feb 2009 · letzter Beitrag vom 31. Mai 2009
 
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.585 Beiträge
 
Delphi 12 Athens
 
#9

Re: Pixel in Millimiter umrechnen mit dieser Funktion ?

  Alt 5. Feb 2009, 09:47
ist der DPI-Wert für deinen Monitor eigentlich richtig eingestellt?
(nicht daß da nur irgendwo 'ne falsche Angabe steht)

ich frag mich auch, was du mit myscreenWidth und myscreenHeight anstellst.
Delphi-Quellcode:
procedure TForm1.PixelsPerMM(canvas: TCanvas; var x, y: Extended);
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 TForm1.Button1Click(Sender: TObject);
var
  X, Y: Extended;
begin
  PixelsPerMM(Form1.Canvas, X, Y);
  Edit1.Text := FloatToStr(X); { the x value holds the pixels per mm horizontally }
  Edit2.Text := FloatToStr(Y); { the y value holds the pixels per mm vertically }

  Edit3.Text := FloatToStr(screen.Width * X);
  Edit4.Text := FloatToStr(screen.Height * Y);
end;

und falls es dir noch nicht aufgefallen ist,
HORZSIZE und VERTSIZE geben bereits die größe in Millimetern an,
wozu willst du also noch rechnen?

(Pixel / 1 mm) * Pixel = mmFürAllePixel
Delphi-Quellcode:
// für jeden Monitor einzeln
var h: hDC;
  hsiz, vsiz: Integer;
begin
  // i = Index des Monitors
  // 0 >= i < Screen.MonitorCount

  h := GetDC(Screen.Monitors[i].Handle);
  hsiz := GetDeviceCaps(h, HORZSIZE);
  vsiz := GetDeviceCaps(h, VERTSIZE);
  ReleaseDC(Screen.Monitors[i].Handle, h);

  Edit1.Text := FloatToStr(hsiz) + 'mm';
  Edit2.Text := FloatToStr(vsiz) + 'mm';
end;


// für den Desktop
var h: hDC;
  hsiz, vsiz: Integer;
begin
  h := GetDC(GetDesktopWindow);
  hsiz := GetDeviceCaps(h, HORZSIZE);
  vsiz := GetDeviceCaps(h, VERTSIZE);
  ReleaseDC(GetDesktopWindow, h);

  Edit1.Text := FloatToStr(hsiz) + 'mm';
  Edit2.Text := FloatToStr(vsiz) + 'mm';
end;
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:28 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz