Strange situation
Strange situation
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.
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.
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Strange situation
Here is the map.bmp file:
https://dropmefiles.com.ua/ru/QwWY
https://dropmefiles.com.ua/ru/QwWY
Code: Select all | Expand
#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
- karinha
- Posts: 7935
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Strange situation
What is wrong? Show with a picture please.
Regards, saludos.
Code: Select all | Expand
#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
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Strange situation
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
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Strange situation
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
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Strange situation
Natter wrote:Here is the map.bmp file:
https://dropmefiles.com.ua/ru/QwWYCode: Select all | Expand
#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
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
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
G. N. Rao.
Hyderabad, India
- karinha
- Posts: 7935
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Strange situation
Excellent mister Nages.
Regards, saludos.
Code: Select all | Expand
#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
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Strange situation
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
G. N. Rao.
Hyderabad, India
- karinha
- Posts: 7935
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Strange situation
CLR_WHITE, CLR_WHITE -> hahahahahaha.
Regards, saludos.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Strange situation
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.
![Image](https://imagizer.imageshack.com/v2/xq90/922/QzxKhZ.png)
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
#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](https://imagizer.imageshack.com/v2/xq90/922/QzxKhZ.png)
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Strange situation
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 !
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
hi,
not sure if "SetWindowRgn" / "CombineRgn" API can help you
under MiniGUI Extended Version i can use
for a Splash-Screen which made all Transparent "Outside" Contour
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
SET REGION OF &name BITMAP &cSaveBmp TRANSPARENT COLOR RGB(252, 253, 252) TO RegionHandle
greeting,
Jimmy
Jimmy