change background file PNG inside .pgm

Post Reply
User avatar
damianodec
Posts: 422
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

change background file PNG inside .pgm

Post by damianodec »

hi,
I have to print some PNG files:

Code: Select all | Expand


oprn:SayImage(1000, 900, "c:\fileImage.png", 1500)

there are some files with black background:
Image
I can not to change background into the file, Is there any way to change background inside source prg and then print ?
thanks
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: change background file PNG inside .pgm

Post by ukoenig »

I think in case of black and white printing
You have to convert the images to NEGATIVE

You can use GIMP ( freeware )
select option < Colors > -> < Invert >

Image

regards
Uwe :D
Last edited by ukoenig on Fri Nov 16, 2018 8:15 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
damianodec
Posts: 422
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: change background file PNG inside .pgm

Post by damianodec »

hi Uwe, thank you for reply.
I haev about 2000 files, in my pgm users insert "code number" and print report of article with file PNG.
it's very compicated change signle file by GMIP and I thought it could be done inside pgm with some function...
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: change background file PNG inside .pgm

Post by ukoenig »

I'm not sure if xImage or FREEIMAGE supports NEGATIV - painting. :?:
There is another possible solution using GIMP as a commandline-tool ( script )

regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: change background file PNG inside .pgm

Post by nageswaragunupudi »

Please try if this approach works for you.

Code: Select all | Expand

#include "fivewin.ch"

#define SRCCOPY      0x00CC0020
#define SRCINVERT    0x00660046

function Main()

   local oPrn, aBmp, nBmpHeight, nRow
   local cFile := "c:\fwh\bitmaps\alphabmp\handnew.bmp"

   PRINT oPrn PREVIEW
   PAGE

   aBmp        := FW_ReadImage( nil, cFile )
   nBmpHeight  := aBmp[ 4 ]

   nRow        := 300
   oPrn:Say( nRow, 300, "Print Normal" )

   nRow  += 100
   DrawBitmap( oPrn:hDCOut, aBmp[ 1 ], nRow, 300, 0, 0, SRCCOPY )

   nRow  += ( nBmpHeight + 100 )
   oPrn:Say( nRow, 200, "Print Negative" )
   nRow  += 100
   DrawBitmap( oPrn:hDCOut, aBmp[ 1 ], nRow, 300, 0, 0, SRCINVERT )

   ENDPAGE

   ENDPRINT

   PalBmpFree( aBmp )

return nil
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
damianodec
Posts: 422
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: change background file PNG inside .pgm

Post by damianodec »

thank you mr. Rao
very good,
I'll try it next week.
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
Posts: 422
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: change background file PNG inside .pgm

Post by damianodec »

hi mr.Rao,
now I working again to this project but I have FiveWin for xHarbour 17.09 - Sep. 2017 and inside this version there is not FW_ReadImage
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: change background file PNG inside .pgm

Post by nageswaragunupudi »

FW_ReadImage() works from FWH 18.01.
For FWH 1709, please use a similar function "WndReadPalBmpEx(...)" with the same syntax.
Please let me know if this works for you.
Regards

G. N. Rao.
Hyderabad, India
User avatar
damianodec
Posts: 422
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: change background file PNG inside .pgm

Post by damianodec »

hi, it's works good.

now I have another question:
how can I know that background of bmp file is black or white ?
thank you
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
Posts: 422
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: change background file PNG inside .pgm

Post by damianodec »

hi,
how can I to zoom bmp file by DrawBitmap function ?

thanks
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Post Reply