My suggestions to HMG_HPDF

Source code related resources

Moderator: Rathinagiri

Post Reply
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

My suggestions to HMG_HPDF

Post by Pablo César »

Rathinagiri wrote:You have to add 'type JPG' for printing JPEG file types.

Actually this you can get from i_print.ch

Code: Select all

#xtranslate @ <nRow> , <nCol> PRINT IMAGE <cImage> ;
	WIDTH <nWidth> ;
	HEIGHT <nheight> ;
	[ <stretch : STRETCH> ] ;
   [ <transparent: TRANSPARENT> ] ;
   [ TRANSPARENTCOLOR <aTransparentColor> ];
   [ TYPE <cType:JPG,PNG> ] ;
	=> ;
   iif( _HMG_SYSDATA \[ 513 \],_HMG_HPDF_IMAGE ( <cImage> , <nRow> , <nCol> , <nheight> , <nWidth> , <.stretch.>, <"cType"> ), _HMG_PRINTER_H_IMAGE ( _HMG_SYSDATA \[ 374 \] , <cImage> , <nRow> , <nCol> , <nheight> , <nWidth> , <.stretch.> , <.transparent.> , <aTransparentColor> ) )
Type is not required for ordinary print. For PDF Print you need to mention the type.
Dear Rathi,

In order to avoid this kind of missing parameter, please considere following possibilities for correction and improvement of the code at _HMG_HPDF_IMAGE function.

Where is default cImageType := "PNG" could be replaced by:
  1. Code: Select all

    If cImageType == Nil
       MsgStop("Missing Image Type!") // It could be added more one item in _HMG_HPDF_Error
       Return Nil
    Endif
     
  2. Code: Select all

    If cImageType == Nil
       cImageType := cFileExt( cImage )
    Endif
You can choose one of these above options.
B.Rgds
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

My suggestions to HMG_HPDF

Post by Pablo César »

Rathinagiri wrote:I see that only images with color information about transparency are shown in HPDF.

If I enable this while saving the above image in GIMP, the image is shown in the PDF.

Image
Very interesting, thank you Rathi for your tips.

Do you think this could it be warned by previous testing if image file has transparency ?

I saw this fi_IsTransparent function in Harbour:
Screen2.png
Screen2.png (101.37 KiB) Viewed 3737 times
Probably it could helps if make some enhance in your code or with BosTaurus implementations.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: My suggestions to HMG_HPDF

Post by Rathinagiri »

Yes. Good suggestions.

Also, we can check whether the cImageFilename contains .jpg and if it is there then we can default the image type to jpg. But if the image is from resources, then it won't have an extension.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

My suggestions to HMG_HPDF

Post by Pablo César »

Rathinagiri wrote:Also, we can check whether the cImageFilename contains .jpg and if it is there then we can default the image type to jpg. But if the image is from resources, then it won't have an extension.
I see, thank you Rathi to share your experience about.
I am study a bit more this case and what it can be done.
I'll revert soon as I have something to indicate.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

My suggestions to HMG_HPDF

Post by Pablo César »

Hi Rathi,

I've got succefully for this case of TYPEs image in h_HMG_HPDF.Prg :D
Screen3.png
Screen3.png (63.24 KiB) Viewed 3674 times
I've tested and works perfectly with file name without image TYPE at HPDFPRINT IMAGE and also thru resource definition.

Code: Select all

// default cImageType := "PNG"
If cImageType == Nil
   cImageType := HMG_Upper( CharRem( ".", cFileExt( cImage ) ) )
   If Empty(cImageType)
      If My_SearchFileFromResources (cImage, "PNG") > 0
	     cImageType := "PNG"
	  Endif
      If My_SearchFileFromResources (cImage, "JPG") > 0
	     cImageType := "JPG"
	  Endif
   Endif
Endif

HB_FUNC (MY_SEARCHFILEFROMRESOURCES)
{
    HRSRC hResource = FindResource (NULL, HMG_parc (1), HMG_parc(2));
	HMG_retnl ((LONG_PTR) hResource );
}
I'm sure all of these FindResource, could be optimized for a generic function that it could be by array returning:
  • nHandle
  • cName
  • cType
  • cTrueName
But my C language knowledge is restricted and poor. :|
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply