I’m developing a little library for printing with SDL
Now I’m writing a function to print a given SDL_Surface
In WIN32 I’ve written something like this:
#ifdef WIN32
HDC GetPrinterDC()
{
char szPrinter[80];
char *szDevice, *szDriver, *szOutput;
DEVMODE PrintDev;
GetProfileString(“windows”, “device”, “,” ,szPrinter, 80);
if (NULL != (szDevice = strtok (szPrinter, “,”)) &&
NULL != (szDriver = strtok (NULL, “,”)) &&
NULL != (szOutput = strtok (NULL, “,”))) {
PrintDev.dmOrientation = DMORIENT_LANDSCAPE;
return CreateDC(szDriver, szDevice, szOutput,&PrintDev);
}
return 0;
}
void PrintSurface (SDL_Surface* Surface)
{
HDC HdcPrinter;
static DOCINFO di = {sizeof (DOCINFO), “Prova”, NULL};
HdcPrinter = GetPrinterDC();
int lx = GetDeviceCaps(HdcPrinter,HORZRES);
int ly = GetDeviceCaps(HdcPrinter,VERTRES);
if (HdcPrinter != NULL) {
if (StartDoc (HdcPrinter, &di) > 0) {
if (StartPage(HdcPrinter) > 0) {
/* *************** I NEED SOME HELP HERE! *************** */
StretchBlt(HdcPrinter, 0, 0, lx, (lx*Surface->h)/Surface->w,
/* HOW I CAN OBTAIN THIS DC ? */,
0, 0, Surface->w, Surface->h, SRCCOPY);
/* ******************************************************* */
if (EndPage(HdcPrinter) > 0) {
EndDoc (HdcPrinter);
}
}
}
}
}
#endif
I need to create a Device Context of a bitmap windows object
that contains surface data. What’s the best way to do this?
Thanks for any help.
Enzo.–
E-mail enzo.gupi at tiscalinet.it
Home page http://enzogupi.interfree.it