FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour change background file PNG inside .pgm
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
change background file PNG inside .pgm
Posted: Wed Nov 14, 2018 03:59 PM
hi,
I have to print some PNG files:
Code (fw): Select all Collapse
oprn:SayImage(1000, 900, "c:\fileImage.png", 1500)

there are some files with black background:

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 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: change background file PNG inside .pgm
Posted: Wed Nov 14, 2018 06:43 PM
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 >



regards
Uwe :-)
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.
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: change background file PNG inside .pgm
Posted: Thu Nov 15, 2018 08:02 AM

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 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: change background file PNG inside .pgm
Posted: Thu Nov 15, 2018 09:57 AM

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.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: change background file PNG inside .pgm
Posted: Fri Nov 16, 2018 09:43 AM
Please try if this approach works for you.

Code (fw): Select all Collapse
#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


Regards



G. N. Rao.

Hyderabad, India
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: change background file PNG inside .pgm
Posted: Fri Nov 23, 2018 03:32 PM

thank you mr. Rao
very good,
I'll try it next week.

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: change background file PNG inside .pgm
Posted: Thu Jan 24, 2019 02:43 PM

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 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: change background file PNG inside .pgm
Posted: Thu Jan 24, 2019 02:56 PM

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
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: change background file PNG inside .pgm
Posted: Thu Jan 24, 2019 03:36 PM

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 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: change background file PNG inside .pgm
Posted: Tue Jan 29, 2019 04:31 PM

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

thanks

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)

Continue the discussion