Grafik drucken

raysprak

Mitglied
Hallo Allerseits!
Folgendes Problem habe ich:
Ich habe den Auftrag, eine Grafik per Code auszudrucken.
Das funktioniert, wenn ich im Druckermenü als Drucker einen PDF-Creator (also einen Softwaredrucker) benutze, wunderbar....
wenn ich jedoch aus dem Druckermenü heraus direkt einen Hardwaredrucker, also einen echten auswähle, nicht....ich meine er druckt mir Text aus, aber nicht die Grafik.
Warum ist das so?
Kann mir da einer weiterhelfen?
Hier der Codeausschnitt:
Code:
        StartPage(pd.hDC);

        // Get printer pixels per inch
        pXPerInch = GetDeviceCaps(pd.hDC, LOGPIXELSX);
        pYPerInch = GetDeviceCaps(pd.hDC, LOGPIXELSY);

        // Get printer absolute resulution
        pXfull = GetDeviceCaps(pd.hDC, HORZRES); 
        pYfull = GetDeviceCaps(pd.hDC, VERTRES); 

        // Get margins
        marginX = (int)((double)pXPerInch * 0.5);
        marginY = (int)((double)pYPerInch * 0.5);

        // Get useable area
        pXuseable = pXfull - (marginX*2);
        pYuseable = pYfull - (marginY*2);

        // Get scaling factor for bitmap
        scaleX = (double)pXuseable / (double)nPixmapX;
        scaleY = (double)pYuseable / (double)nPixmapY;
        scale = scaleX < scaleY ? scaleX : scaleY;

        // Get scaling size for bitmap
        pXscaled = (int)((double)nPixmapX * scale);
        pYscaled = (int)((double)nPixmapY * scale);

        // Scale and print bitmap
        StretchBlt(pd.hDC, marginX, marginY+12, pXscaled, pYscaled, global.chartDC, 0, 0, nPixmapX, nPixmapY, SRCCOPY);

        // Get size of headline and footer
        GetTextExtentPoint32(pd.hDC, headline.c_str(), headline.length(), &sizeHeadline);
        GetTextExtentPoint32(pd.hDC, footer, strlen(footer), &sizeFooter);

        // Get position of headline and footer
        posHeadline.x = marginX + ((pXuseable - sizeHeadline.cx) / 2);
        posHeadline.y = (marginY - sizeHeadline.cy) / 2;

        posFooter.x = marginX + ((pXuseable - sizeFooter.cx) / 2);
        posFooter.y = pYfull - ((marginY + sizeFooter.cy)/ 4);
    
        // Print headline and footer
        TextOut(pd.hDC, posHeadline.x, posHeadline.y, headline.c_str(), headline.length()); 
        

        EndPage(pd.hDC);
 
Danke!
Hat sich erledigt.
Problem war folgendes:

Code:
StretchBlt(pd.hDC, marginX, marginY+12, pXscaled, pYscaled, global.chartDC, 0, 0, nPixmapX, nPixmapY, SRCCOPY);
                                                                            ^  ^            
StretchBlt(pd.hDC, marginX, marginY+12, pXscaled, pYscaled, global.chartDC, 1, 1, nPixmapX, nPixmapY, SRCCOPY);

Warum das so ist, weiß ich auch nicht......wenn jemand das weiß, dann bitte durchgeben....
dicken gruß
 
Zurück