Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Metafile/MetafileCanvas and dpi higher than 96.



Permlink Replies: 4 - Last Post: Dec 5, 2014 2:32 PM Last Post By: Wojciech Pomian...
Ralf Stocker

Posts: 121
Registered: 12/24/04
Metafile/MetafileCanvas and dpi higher than 96.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 30, 2014 4:36 AM
A Metafiles is connected to a device context (DC) with 96 dpi (standard screen dpi).
Now I have the problem, that the Drawing operation into a high resolution metafile (40.000 pixels in size)
beyond pixel position 1280 (my monitor screen resolution), are ignored by the MetafileCanvas.Draw operation.
The MetafileCanvas.Draw thinks, that the drawing happens outside/off-screen and skips the Draw operation.
What is the solution here? How can I teach the MetafileCanvas a higher dpi resolution or avoid the clipping / none drawing here?

Metafile.Width := 40000;
Metafile.Height := 40000;
MetafileCanvas := TMetafileCanvas.Create(Metafile, 0);
MetafileCanvas.Draw(0, 0, other_src_metafile); //ok, drawing is visible!
MetafileCanvas.Draw(1280, 0, other_src_metafile); //nok!!! drawing is not visible / nothing is drawn!
MetafileCanvas.Free;

best regards
Ralf
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Metafile/MetafileCanvas and dpi higher than 96. [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 30, 2014 11:29 AM   in response to: Ralf Stocker in response to: Ralf Stocker
Ralf wrote:

The MetafileCanvas.Draw thinks, that the drawing happens
outside/off-screen and skips the Draw operation.

You are not providing an HDC to the TMetaFileCanvas constructor, so it calls
GetDC(0) to get an HDC for the screen.

What is the solution here? How can I teach the MetafileCanvas a higher
dpi resolution or avoid the clipping / none drawing here?

Try creating a TBitmap of the desired dimension and resolution, then use
the TBitmap.Canvas.Handle as the HDC.

--
Remy Lebeau (TeamB)
Ralf Stocker

Posts: 121
Registered: 12/24/04
Re: Metafile/MetafileCanvas and dpi higher than 96. [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 30, 2014 1:32 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Ralf wrote:

The MetafileCanvas.Draw thinks, that the drawing happens
outside/off-screen and skips the Draw operation.

You are not providing an HDC to the TMetaFileCanvas constructor, so it calls
GetDC(0) to get an HDC for the screen.

What is the solution here? How can I teach the MetafileCanvas a higher
dpi resolution or avoid the clipping / none drawing here?

Try creating a TBitmap of the desired dimension and resolution, then use
the TBitmap.Canvas.Handle as the HDC.

--
Remy Lebeau (TeamB)

Hi Remy,

is there an another solution? I don't want to have such a huge a bitmap. Only a vector metafile.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Metafile/MetafileCanvas and dpi higher than 96. [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 30, 2014 2:40 PM   in response to: Ralf Stocker in response to: Ralf Stocker
Ralf wrote:

is there an another solution? I don't want to have such
a huge a bitmap. Only a vector metafile.

You need an HDC one way or the other. If you cant use a bitmap, you will
likely have to use a hidden/offscreen window instead. As I said earlier,
the screen HDC is used otherwise, which should be fine for resolution but
not for large dimensions.

--
Remy Lebeau (TeamB)
Wojciech Pomian...

Posts: 11
Registered: 6/5/04
Re: Metafile/MetafileCanvas and dpi higher than 96. [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 5, 2014 2:32 PM   in response to: Ralf Stocker in response to: Ralf Stocker
Ralf Stocker wrote:
Remy Lebeau (TeamB) wrote:
Ralf wrote:

The MetafileCanvas.Draw thinks, that the drawing happens
outside/off-screen and skips the Draw operation.

You are not providing an HDC to the TMetaFileCanvas constructor, so it calls
GetDC(0) to get an HDC for the screen.

What is the solution here? How can I teach the MetafileCanvas a higher
dpi resolution or avoid the clipping / none drawing here?

Try creating a TBitmap of the desired dimension and resolution, then use
the TBitmap.Canvas.Handle as the HDC.

--
Remy Lebeau (TeamB)

Hi Remy,

is there an another solution? I don't want to have such a huge a bitmap. Only a vector metafile.

You are right - creating huge bitmap only to satisfy TCanvas (unreasonable) requiremen would be a waste.
You need to part with TCanvas and code directly against windows GDI. First, get familiar with DC (device context) and coordinate transformations. Then use CreateEnhMetafile. Be warned however that metafile concept is tied to GDI, which is becoming obsolete.

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02