Copying a Juce Image to a Windows Device context


I am used to copying images and such between DC’s, but now I am trying to get a juce Image to a DC. I see how I can get the (I think) bitmap from an image, but placing it into a DC is proving difficult, and the documentation seems a little sparse on msdn. Purpose is so I can print it out.

There are a few steps I need to do, first I need to get the pixel per inch from the printer. I need to scale the image to match so it will be the same size on print as on screen. I would prefer to go the emf route and may end up doing that, but I already have what I need to print set using a Juce::Graphics, which, when subclassed, would make an excellent emf generator. EMF is far nicer as I don’t have to care what proportions the printer is and such, it handles that automatically. Still unsure how to get a Juce::Image to print however. I am attempting to print a report, no fancy graphics, and is excellently suited for EMF. So, does anyone have experience or thoughts on how to copy a juce image to a windows device context?


Well that’s how all the windows get drawn - take a look inside juce_win32_Windowing.cpp, in handlePaintMessage()


Ok, I feel stupid. >.>

Thanks for the help.


Okay, I should have it able to print a juce Image now. I have it so you subclass from this, and when you want to print you call PrintPage, which it then sets up the printer option (opening the standard windows printer dialog, like choosing pages and such, I plan to add multi-page support here next), then calls a callback paintPage(Graphics &g) with the graphic being setup to the correct proportions for the options and dpi of the chosen printer, then it prints out that page. Now, to just find one of my five printers…