Page 1 of 1

Strange situation

PostPosted: Mon Oct 25, 2021 11:11 am
by Natter
Hi,

I need to paint over the space around the polygon in the picture - floodfill(). On the window, using the :line() method, I limit the green polygon. I make a bitmap of this window FW_MakeYourBitmap() and save it to the file FW_Save Image(). - my.bmp
1. When viewing .bmp in Windows the polygon frame has turned black
2. When opening .bmp in TBitmap or Timage the polygon frame turns white

How can I use floodfill() in this situation
if the border color is not clear.

Re: Strange situation

PostPosted: Wed Oct 27, 2021 9:29 pm
by nageswaragunupudi
Can we have a small sample?

Re: Strange situation

PostPosted: Fri Oct 29, 2021 6:35 am
by Natter
Here is the map.bmp file:
https://dropmefiles.com.ua/ru/QwWY

Code: Select all  Expand view
#include "FiveWin.ch"

procedure Main
local siz:={575,659}
private oFrg

  DEFINE DIALOG oFrg FROM 0,0 TO siz[1], siz[2]  PIXEL ;
                         STYLE nOR(WS_POPUP, WS_BORDER)
  ACTIVATE DIALOG oFrg  ON INIT Frg_Ini()
return

procedure Frg_Ini
local oCl

*  @ 0,0 BITMAP oCl  OF oFrg  SIZE oFrg:nWidth, oFrg:nHeight  PIXEL  NOBORDER
  oCl:=TXImage():New(0, 0, oFrg:nWidth, oFrg:nHeight,, oFrg,, .F.)  
*  oCl:bPainted:={|hDc| FloodFill(hDc, 0, 0, CLR_BLACK, CLR_WHITE)}
  oCl:SetSource("map.bmp")
  oFrg:Center()
return
 

Re: Strange situation

PostPosted: Fri Oct 29, 2021 2:15 pm
by karinha
What is wrong? Show with a picture please.

Code: Select all  Expand view

#Include "FiveWin.ch"

STATIC oDlg

FUNCTION Main()

   LOCAL aGrad
   LOCAL Siz := { 600, 800 }

   aGrad := { { 0.30, CLR_WHITE, CLR_WHITE },{ 0.50, CLR_WHITE, CLR_WHITE } }

   DEFINE DIALOG oDlg FROM 0, 0 TO Siz[1], Siz[2] PIXEL TRUEPIXEL ;
      STYLE nOR( WS_POPUP, WS_BORDER ) GRADIENT aGrad

   oDlg:lModal := .T.

   ACTIVATE DIALOG oDlg ON INIT Frg_Ini()

RETURN NIL

FUNCTION Frg_Ini()

   LOCAL oCl

   oCl := TXImage():New( 0, 0, oDlg:nWidth, oDlg:nHeight,, oDlg,, .F. )

   oCl:SetSource( "Map.bmp" )

   oDlg:Center()

RETURN NIL

// END
 


Regards, saludos.

Re: Strange situation

PostPosted: Fri Oct 29, 2021 2:46 pm
by nageswaragunupudi
karinha wrote:What is wrong? Show with a picture please.


He did not say there is anything wrong with the code.
He also sent "map.bmp". You can download and view the image.
His problem is floodfill.
We need to help him with that issue, which includes the issue of the color of the rectangle border.'

Re: Strange situation

PostPosted: Fri Oct 29, 2021 2:59 pm
by nageswaragunupudi
Natter wrote:Hi,
1. When viewing .bmp in Windows the polygon frame has turned black
2. When opening .bmp in TBitmap or Timage the polygon frame turns white


That means the color used for the border is an alpha color/ transparent color.
We need the boundary in RGB color to use floodfill

Re: Strange situation

PostPosted: Fri Oct 29, 2021 3:17 pm
by nageswaragunupudi
Natter wrote:Here is the map.bmp file:
https://dropmefiles.com.ua/ru/QwWY

Code: Select all  Expand view
#include "FiveWin.ch"

procedure Main
local siz:={575,659}
private oFrg

  DEFINE DIALOG oFrg FROM 0,0 TO siz[1], siz[2]  PIXEL ;
                         STYLE nOR(WS_POPUP, WS_BORDER)
  ACTIVATE DIALOG oFrg  ON INIT Frg_Ini()
return

procedure Frg_Ini
local oCl

*  @ 0,0 BITMAP oCl  OF oFrg  SIZE oFrg:nWidth, oFrg:nHeight  PIXEL  NOBORDER
  oCl:=TXImage():New(0, 0, oFrg:nWidth, oFrg:nHeight,, oFrg,, .F.)  
*  oCl:bPainted:={|hDc| FloodFill(hDc, 0, 0, CLR_BLACK, CLR_WHITE)}
  oCl:SetSource("map.bmp")
  oFrg:Center()
return
 


This entire code can be written as:
Code: Select all  Expand view
  DEFINE DIALOG oDlg SIZE 575,569 PIXEL TRUEPIXEL
   @ 0,0 XIMAGE oImg FILE ".\Natter\map.bmp" SIZE 0,0 OF oDlg NOBORDER
   ACTIVATE DIALOG oDlg CENTERED
 

with the same functionality.
As you said, you will see the border line in CLR_WHITE. That is because the background color of XImage control is CLR_WHITE.

Now add one line of code:
Code: Select all  Expand view
  DEFINE DIALOG oDlg SIZE 575,569 PIXEL TRUEPIXEL
   @ 0,0 XIMAGE oImg FILE ".\Natter\map.bmp" SIZE 0,0 OF oDlg NOBORDER
   oImg:SetColor( CLR_GRAY, CLR_HRED ) // Added
   ACTIVATE DIALOG oDlg CENTERED
 

Now you will see the border of the polygon in CLR_HRED.
You can test changing the background color in oImg:SetColor() and see that the border is shown in the background color of the control.

Now, this takes us back to drawing the polygon using Line() method in the first place.

The 4th and last param of FW_MakeYourBitmap() is lAlpha. Did you set this to .T. ?

Please wait for my next posting

Re: Strange situation

PostPosted: Fri Oct 29, 2021 3:55 pm
by karinha
Excellent mister Nages.

Code: Select all  Expand view

#Include "FiveWin.ch"

STATIC oDlg

FUNCTION Main()

   LOCAL aGrad, oImg
   LOCAL Siz := { 600, 800 }

   aGrad := { { 0.30, CLR_WHITE, CLR_WHITE },{ 0.50, CLR_WHITE, CLR_WHITE } }

   DEFINE DIALOG oDlg FROM 0, 0 TO Siz[1], Siz[2] PIXEL TRUEPIXEL ;
      STYLE nOR( WS_POPUP, WS_BORDER ) GRADIENT aGrad

   @ 0,0 XIMAGE oImg FILE ".\map.bmp" SIZE 0,0 OF oDlg NOBORDER

   oImg:SetColor( CLR_GRAY, CLR_HRED ) // Added Mister Nages

   ACTIVATE DIALOG oDlg CENTERED

   //ON INIT Frg_Ini()

RETURN NIL

FUNCTION Frg_Ini()

   LOCAL oCl

   oCl := TXImage():New( 0, 0, oDlg:nWidth, oDlg:nHeight,, oDlg,, .F. )

   oCl:SetSource( "Map.bmp" )

   oDlg:Center()

RETURN NIL

// END
 


Regards, saludos.

Re: Strange situation

PostPosted: Fri Oct 29, 2021 5:30 pm
by nageswaragunupudi
Why Gradient, when we are using the entire area of the dialog? Is it not a waste of processor time?

Re: Strange situation

PostPosted: Fri Oct 29, 2021 5:39 pm
by karinha
CLR_WHITE, CLR_WHITE -> hahahahahaha.

Regards, saludos.

Re: Strange situation

PostPosted: Fri Oct 29, 2021 5:42 pm
by nageswaragunupudi
Mr. Natter

It appears that your map.bmps are all alpha bitmaps.
We need to start with non-alpha bitmaps.
Then everything works as expected.
I am giving here a sample using a non-alpha bitmap "sea.bmp" in \fwh\samples folder.

Code: Select all  Expand view

#include "fivewin.ch"

function Main()

   local oWnd, aBmp, cBmp  := "c:\fwh\bitmaps\sea.bmp"
   local hNew

   hNew  := FW_MakeYourBitmap( 512, 384, <|hDC,w,h|
            local hPen  := CreatePen( PS_SOLID, 3, CLR_HRED )

            FW_DrawImage( hDC, cBmp, { 0,0,h,w } )
            MoveTo( hDC, 280,  50 )
            LineTo( hDC, 500, 300, hPen )
            LineTo( hDC,  30, 200, hPen )
            LineTo( hDC, 280,  50, hPen )
            FloodFill( hDC, 1, 1, CLR_HRED, CLR_HGREEN )

            DeleteObject( hPen )
            return nil
            >, .f. )

   FW_SaveImage( hNew, "new.bmp" )
   DeleteObject( hNew )

   XImage( "new.bmp" )

return nil
 


Image

Re: Strange situation

PostPosted: Fri Oct 29, 2021 6:52 pm
by Natter
Thank you very much, Mr.Ro !
It seems that the problem is precisely that to draw the contour in using the on:Line() method of any color. As a result, I solved the problem - first using FloodFill, and then saving the fragment to a file (although I couldn't get a contour around the picture). I stopped at .png files because they are smaller and have a transparent background.
Thanks again !

Re: Strange situation

PostPosted: Sat Oct 30, 2021 7:33 am
by Jimmy
hi,
although I couldn't get a contour around the picture

not sure if "SetWindowRgn" / "CombineRgn" API can help you

under MiniGUI Extended Version i can use
Code: Select all  Expand view
   SET REGION OF &name BITMAP &cSaveBmp TRANSPARENT COLOR RGB(252, 253, 252) TO RegionHandle
for a Splash-Screen which made all Transparent "Outside" Contour