Printing in GDI+

Printing in GDI+

Postby byte-one » Thu Feb 09, 2017 3:05 pm

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!?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Printing in GDI+

Postby nageswaragunupudi » Thu Feb 09, 2017 3:27 pm

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.

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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Printing in GDI+

Postby byte-one » Thu Feb 09, 2017 3:58 pm

Thanks. I will do some tests on next days before!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Printing in GDI+

Postby byte-one » Thu Feb 09, 2017 6:07 pm

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)!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Printing in GDI+

Postby byte-one » Sun Feb 12, 2017 3:53 pm

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+.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Printing in GDI+

Postby nageswaragunupudi » Sun Feb 12, 2017 6:07 pm

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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Printing in GDI+

Postby byte-one » Mon Feb 13, 2017 9:05 am

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!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Printing in GDI+

Postby nageswaragunupudi » Mon Feb 13, 2017 10:43 am

Nice.
I do not have the original png but I tried to view and print from your webpage.
Code: Select all  Expand view  RUN
//----------------------------------------------------------------------------//

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
Image

Print Preview:
Image

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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Printing in GDI+

Postby byte-one » Mon Feb 13, 2017 11:06 am

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.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Printing in GDI+

Postby nageswaragunupudi » Mon Feb 13, 2017 12:30 pm

We need to address this:
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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Printing in GDI+

Postby byte-one » Mon Feb 13, 2017 1:00 pm

Thats the point!! This concerns not only transparency but also paths, transforms,....
Could this for the FWH-team a target?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Printing in GDI+

Postby nageswaragunupudi » Mon Feb 13, 2017 4:10 pm

What is now possible to do with FWH:
GDI+ Shapes (paths) in a simple way.
Code: Select all  Expand view  RUN
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:
Image

Print Preview:
Image

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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 75 guests