Printing in GDI+
Printing in GDI+
I found, that printing graphics made from GDI+ are ugly when using transparent modes. GDI+ has a own EMF-format. Maybe we should use it for this!?
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Printing in GDI+
In FWH libraries, we are not using GDI+ for printing. We need to do more tests on this before implementation. For now we are using pure GDI only.
Can you elaborate more please?
I found, that printing graphics made from GDI+ are ugly when using transparent modes. GDI+ has a own EMF-format. Maybe we should use it for this!?
Can you elaborate more please?
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Printing in GDI+
It is not a way to print transparent areas to most printers. We must write the graphic into bitmap (or EMF) an then draw the resulting bitmap (or play the EMF)!
Re: Printing in GDI+
It seems the method to print transparent areas or pages in GDI+ could as best with as first record in a EMF+ file and then play this file.
See also: https://msdn.microsoft.com/en-us/library/windows/desktop/ms536391(v=vs.85).aspx
I have tested with write to a empty bmp or png. Is functioning, but i must know the width and hight of the picture. In EMF+ the size is automatically adjusted and updated!
This all can (and should) be included in printer-class. If we use GDI+ then also the printer-output should be represent the features of GDI+.
See also: https://msdn.microsoft.com/en-us/library/windows/desktop/ms536391(v=vs.85).aspx
I have tested with write to a empty bmp or png. Is functioning, but i must know the width and hight of the picture. In EMF+ the size is automatically adjusted and updated!
This all can (and should) be included in printer-class. If we use GDI+ then also the printer-output should be represent the features of GDI+.
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Printing in GDI+
Can you please make me understand what is it we are going to achieve that we can not do with present print class using normal GDI? We are now able to print any image without using GDI+
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Printing in GDI+
In the following link you see a image with transparent circles maked with GDI+. When paint this graphic i use a normal hDc and make a file. When this hDc is a printer i loose the transparence areas and full colors are painted on most printers.
http://byte-one.com/150.png
As first step you could use in printer/preview classes the EMF+ format from GDI+! This format saves also the tranparence!
http://byte-one.com/150.png
As first step you could use in printer/preview classes the EMF+ format from GDI+! This format saves also the tranparence!
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Printing in GDI+
Nice.
I do not have the original png but I tried to view and print from your webpage.
I am able to see through the translucent circles.
Viewing in Window

Print Preview:

I see it well in my hard copy too.
Can you try this small program and kindly offer your comments?
I do not have the original png but I tried to view and print from your webpage.
Code: Select all | Expand
//----------------------------------------------------------------------------//
function png150()
local oWnd, oBar
local cPng := "http://byte-one.com/150.png"
local aPalBmp
DEFINE WINDOW oWnd
DEFINE BUTTONBAR oBar OF oWnd SIZE 80,32
DEFINE BUTTON OF oBar PROMPT "Print" CENTER ACTION PrintPng( cPng )
aPalBmp := oWnd:ReadPalBmpEx( cPng, , .t. )
ACTIVATE WINDOW oWnd ON PAINT oWnd:SayPalBmp( aPalBmp )
PalBmpFree( aPalBmp )
return nil
function PrintPng( cPng )
local oPrn
PRINT oPrn PREVIEW
PAGE
@ 4,2 PRINT TO oPrn IMAGE cPng SIZE 5,5 INCHES
ENDPAGE
ENDPRINT
return nil
I am able to see through the translucent circles.
Viewing in Window

Print Preview:

I see it well in my hard copy too.
Can you try this small program and kindly offer your comments?
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Printing in GDI+
Yes, you are right! A complete picture to print is ok.
But to write to a printer-hDc (oPrint-class) the same transparent circles is not possible! Is always full color. Only some printers are able to print transparent output.
The png i make with CreateCompatibleBitMap( ) and write to a file.
But to write to a printer-hDc (oPrint-class) the same transparent circles is not possible! Is always full color. Only some printers are able to print transparent output.
The png i make with CreateCompatibleBitMap( ) and write to a file.
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Printing in GDI+
We need to address this:
Whether we directly write to print dc or otherwise, we need to have the final image on the printer.
Right?
Yes, I agree. Not all printer drivers support alpha colors.
But to write to a printer-hDc (oPrint-class) the same transparent circles is not possible!
Whether we directly write to print dc or otherwise, we need to have the final image on the printer.
Right?
Yes, I agree. Not all printer drivers support alpha colors.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Printing in GDI+
Thats the point!! This concerns not only transparency but also paths, transforms,....
Could this for the FWH-team a target?
Could this for the FWH-team a target?
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Printing in GDI+
What is now possible to do with FWH:
GDI+ Shapes (paths) in a simple way.
Window:

Print Preview:

Top image is drawn directly with GDI+ on the Printer's Preview DC (i.e, emf)
Bottom image is GDI Bitmap generated by GDI+ from the vector information of the Shapes
This prints on my printer. Not really sure how compatible is this with other printers.
GDI+ Shapes (paths) in a simple way.
Code: Select all | Expand
function TestShapes()
local oWnd
local aShapes := {}
local aShape
// Triangle
aShape := { "Line", NARGB( 180, CLR_YELLOW ), 0, 1024, 1024, 0, 0, 1023, 0, 1023, 1023, .T. }
AAdd( aShapes, aShape )
aShape := { "Line", CLR_HRED, 3, 1024, 1024, 0, 0, 1023, 0, 1023, 1023, .T. }
AAdd( aShapes, aShape )
// Circle
aShape := { "Elli", NARGB( 128, CLR_HGREEN ), 0, 1024, 1024, 32, 32, 1023-32, 1023-32 }
AAdd( aShapes, aShape )
aShape := { "Elli", CLR_GREEN, 3, 1024, 1024, 32, 32, 1023-32, 1023-32 }
AAdd( aShapes, aShape )
// Rectangle
aShape := { "Rect", NARGB( 128, CLR_BLACK ), 0, 1024, 1024, 484, 256, 640, 1023 }
AAdd( aShapes, aShape )
aShape := { "Rect", CLR_WHITE, 6, 1024, 1024, 484, 256, 640, 1023 }
AAdd( aShapes, aShape )
DEFINE WINDOW oWnd TITLE "FWH GDI+ SHAPES"
oWnd:nHeight := 500
oWnd:nWidth := 400
@ 400,40 BUTTON "Print" SIZE 100,30 PIXEL OF oWnd ;
ACTION PrintShapes( aShapes )
ACTIVATE WINDOW oWnd CENTERED ;
ON PAINT oWnd:DrawShapes( aShapes, { 40, 40, 340, 340 } )
return nil
function PrintShapes( aShapes )
local oPrn
local hBmp
hBmp := FW_CreateBitmap( { 1024, 1024, aShapes } )
PRINT oPrn PREVIEW
PAGE
// GDI+ draw on oPrn:hDCOut
FW_DrawShapes( oPrn:hDCOut, aShapes, { 50,50,300,300 } )
// Print as GDI Bitmap
@ 4,1 PRINT TO oPrn IMAGE hBmp SIZE 4,4 INCHES
ENDPAGE
ENDPRINT
DeleteObject( hBmp )
return nil
Window:

Print Preview:

Top image is drawn directly with GDI+ on the Printer's Preview DC (i.e, emf)
Bottom image is GDI Bitmap generated by GDI+ from the vector information of the Shapes
This prints on my printer. Not really sure how compatible is this with other printers.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India