Strange situation

Strange situation

Postby Natter » Mon Oct 25, 2021 11:11 am

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.
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Strange situation

Postby nageswaragunupudi » Wed Oct 27, 2021 9:29 pm

Can we have a small sample?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Strange situation

Postby Natter » Fri Oct 29, 2021 6:35 am

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
 
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Strange situation

Postby karinha » Fri Oct 29, 2021 2:15 pm

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7316
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Strange situation

Postby nageswaragunupudi » Fri Oct 29, 2021 2:46 pm

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.'
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Strange situation

Postby nageswaragunupudi » Fri Oct 29, 2021 2:59 pm

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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Strange situation

Postby nageswaragunupudi » Fri Oct 29, 2021 3:17 pm

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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Strange situation

Postby karinha » Fri Oct 29, 2021 3:55 pm

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7316
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Strange situation

Postby nageswaragunupudi » Fri Oct 29, 2021 5:30 pm

Why Gradient, when we are using the entire area of the dialog? Is it not a waste of processor time?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Strange situation

Postby karinha » Fri Oct 29, 2021 5:39 pm

CLR_WHITE, CLR_WHITE -> hahahahahaha.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7316
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Strange situation

Postby nageswaragunupudi » Fri Oct 29, 2021 5:42 pm

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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Strange situation

Postby Natter » Fri Oct 29, 2021 6:52 pm

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 !
Natter
 
Posts: 1120
Joined: Mon May 14, 2007 9:49 am

Re: Strange situation

Postby Jimmy » Sat Oct 30, 2021 7:33 am

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
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1590
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 21 guests