Discussion:
shaped sample doesn't work
leo.zhou
2014-06-09 13:42:54 UTC
Permalink
Hi guys,
I have to implement a shaped dialog using a bitmap on Mac OS X 10.9. I
downloaded the latest trunk version of wxwidgets and compile the samples
without any error. When I click "Show shaped window" in shaped app, it
shows debug alert as follows:

../src/osx/carbon/region.cpp(1016): assert "m_refData" failed in
DoOffset(): invalid wxRegion

Call stack:
[00] wxOSX_drawRect(NSView*, objc_selector*, CGRect)
[01] -[NSView _drawRect:clip:]
[02] -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
[03] -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
[04] -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
[05] -[NSNextStepFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
[06] -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
[07] -[NSView displayIfNeeded]
[08] -[NSNextStepFrame displayIfNeeded]
[09] -[NSWindow
_reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:]
[10] -[NSWindow
_doOrderWindow:relativeTo:findKey:forCounter:force:isModal:]
[11] -[NSWindow orderWindow:relativeTo:]
[12] -[NSWindow makeKeyAndOrderFront:]
[13] wxNonOwnedWindowCocoaImpl::Show(bool)
[14] wxNonOwnedWindow::Show(bool)
[15] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[16] wxEvtHandler::ProcessEventLocally(wxEvent&)
[17] wxEvtHandler::ProcessEvent(wxEvent&)
[18] wxWindowBase::TryAfter(wxEvent&)
[19] wxEvtHandler::ProcessEvent(wxEvent&)
[20] wxEvtHandler::SafelyProcessEvent(wxEvent&)
Do you want to stop the program?
You can also choose [Cancel] to suppress further warnings.

Regards,
Leo
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
leo.zhou
2014-06-09 13:53:46 UTC
Permalink
圚 2014幎6月9日星期䞀UTC+8䞋午9时42分54秒leo.zhou写道
Post by leo.zhou
Hi guys,
I have to implement a shaped dialog using a bitmap on Mac OS X 10.9. I
downloaded the latest trunk version of wxwidgets and compile the samples
without any error. When I click "Show shaped window" in shaped app, it
../src/osx/carbon/region.cpp(1016): assert "m_refData" failed in
DoOffset(): invalid wxRegion
[00] wxOSX_drawRect(NSView*, objc_selector*, CGRect)
[01] -[NSView _drawRect:clip:]
[02] -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
[03] -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
[04] -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
[05] -[NSNextStepFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
[06] -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
[07] -[NSView displayIfNeeded]
[08] -[NSNextStepFrame displayIfNeeded]
[09] -[NSWindow
_reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:]
[10] -[NSWindow
_doOrderWindow:relativeTo:findKey:forCounter:force:isModal:]
[11] -[NSWindow orderWindow:relativeTo:]
[12] -[NSWindow makeKeyAndOrderFront:]
[13] wxNonOwnedWindowCocoaImpl::Show(bool)
[14] wxNonOwnedWindow::Show(bool)
[15] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)
[16] wxEvtHandler::ProcessEventLocally(wxEvent&)
[17] wxEvtHandler::ProcessEvent(wxEvent&)
[18] wxWindowBase::TryAfter(wxEvent&)
[19] wxEvtHandler::ProcessEvent(wxEvent&)
[20] wxEvtHandler::SafelyProcessEvent(wxEvent&)
Do you want to stop the program?
You can also choose [Cancel] to suppress further warnings.
Regards,
Leo
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-06-10 00:39:51 UTC
Permalink
On Mon, 9 Jun 2014 06:42:54 -0700 (PDT) leo.zhou wrote:

l> I have to implement a shaped dialog using a bitmap on Mac OS X 10.9. I
l> downloaded the latest trunk version of wxwidgets and compile the samples
l> without any error. When I click "Show shaped window" in shaped app, it
l> shows debug alert as follows:
l>
l> ../src/osx/carbon/region.cpp(1016): assert "m_refData" failed in
l> DoOffset(): invalid wxRegion

I've fixed this now in both 3.0 branch and the trunk, thanks for
reporting,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
leo.zhou
2014-06-10 06:32:49 UTC
Permalink
圚 2014幎6月10日星期二UTC+8䞊午8时40分10秒Vadim Zeitlin写道
Post by Vadim Zeitlin
l> I have to implement a shaped dialog using a bitmap on Mac OS X 10.9. I
l> downloaded the latest trunk version of wxwidgets and compile the samples
l> without any error. When I click "Show shaped window" in shaped app, it
l>
l> ../src/osx/carbon/region.cpp(1016): assert "m_refData" failed in
l> DoOffset(): invalid wxRegion
I've fixed this now in both 3.0 branch and the trunk, thanks for
reporting,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Thanks. I've compiled the latest version. When I use my png file instead
and modify the code as follows:

wxColour color;

color.SetRGB(0x008c3230);

SetShape(wxRegion(m_bmp, color));

The shaped window don't show up, giving this warning message "iCCP: known
incorrect sRGB profile". I have no idea what's going wrong. The png file is
definitely valid.

Regards,

Leo
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-06-10 12:53:28 UTC
Permalink
On Mon, 9 Jun 2014 23:32:49 -0700 (PDT) leo.zhou wrote:

l> Thanks. I've compiled the latest version. When I use my png file instead
l> and modify the code as follows:
l>
l> wxColour color;
l>
l> color.SetRGB(0x008c3230);
l>
l> SetShape(wxRegion(m_bmp, color));
l>
l> The shaped window don't show up, giving this warning message "iCCP: known
l> incorrect sRGB profile". I have no idea what's going wrong. The png file is
l> definitely valid.

It isn't according to libpng, please search Trac for more details and for
the explanation of how to work around this.

However this warning doesn't explain why it doesn't work for you. My guess
would be that you didn't realize that wxColour::SetRGB() takes the colour
in (Windows) BGR format and not the usual RGB and so your shape is empty.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
leo.zhou
2014-06-10 14:36:53 UTC
Permalink
圚 2014幎6月10日星期二UTC+8䞋午8时53分53秒Vadim Zeitlin写道
Post by Vadim Zeitlin
l> Thanks. I've compiled the latest version. When I use my png file instead
l>
l> wxColour color;
l>
l> color.SetRGB(0x008c3230);
l>
l> SetShape(wxRegion(m_bmp, color));
l>
l> The shaped window don't show up, giving this warning message "iCCP: known
l> incorrect sRGB profile". I have no idea what's going wrong. The png file is
l> definitely valid.
It isn't according to libpng, please search Trac for more details and for
the explanation of how to work around this.
However this warning doesn't explain why it doesn't work for you. My guess
would be that you didn't realize that wxColour::SetRGB() takes the colour
in (Windows) BGR format and not the usual RGB and so your shape is empty.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Thanks! I've converted RGB to BGR. Maybe my png file is incompatible with
libpng. I try to use bmp instead but still doesn't work. The window can
only show up with wxWHITE. If I use wxBLACK, wxBLUE or something, the
window cannot be seen. Ridiculous! Maybe there is some bug in wxwidgets.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-06-10 17:32:07 UTC
Permalink
On Tue, 10 Jun 2014 07:36:53 -0700 (PDT) leo.zhou wrote:

l> Thanks! I've converted RGB to BGR. Maybe my png file is incompatible with
l> libpng. I try to use bmp instead but still doesn't work. The window can
l> only show up with wxWHITE. If I use wxBLACK, wxBLUE or something, the
l> window cannot be seen. Ridiculous! Maybe there is some bug in wxwidgets.

Please try to debug wxRegion creation. I'm not sure what's going on here
and won't have time to debug it any very soon.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
leo.zhou
2014-06-11 07:39:05 UTC
Permalink
圚 2014幎6月11日星期䞉UTC+8䞊午1时32分27秒Vadim Zeitlin写道
Post by Vadim Zeitlin
l> Thanks! I've converted RGB to BGR. Maybe my png file is incompatible with
l> libpng. I try to use bmp instead but still doesn't work. The window can
l> only show up with wxWHITE. If I use wxBLACK, wxBLUE or something, the
l> window cannot be seen. Ridiculous! Maybe there is some bug in wxwidgets.
Please try to debug wxRegion creation. I'm not sure what's going on here
and won't have time to debug it any very soon.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
sorry, I don't quite understand the source code. In shaped sample code, I
just changed one line.

SetShape(wxRegion(m_bmp, *wxWHITE)); --> SetShape(wxRegion(m_bmp,
*wxBLACK));

and the window never showed up. I know the star.png doesn't have a pixel of
black color, but the reasonable result should be the window showing up
without any part hidden, right? Hope this will be fixed on the upcoming
3.0.1 version. Thanks!


Regards,

Leo
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-06-11 13:08:13 UTC
Permalink
On Wed, 11 Jun 2014 00:39:05 -0700 (PDT) leo.zhou wrote:

l> sorry, I don't quite understand the source code. In shaped sample code, I
l> just changed one line.
l>
l> SetShape(wxRegion(m_bmp, *wxWHITE)); --> SetShape(wxRegion(m_bmp,
l> *wxBLACK));
l>
l> and the window never showed up. I know the star.png doesn't have a pixel of
l> black color, but the reasonable result should be the window showing up
l> without any part hidden, right?

Why? If the region is empty, it seems normal to me that nothing is shown.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
leo.zhou
2014-06-11 15:20:21 UTC
Permalink
圚 2014幎6月11日星期䞉UTC+8䞋午9时08分35秒Vadim Zeitlin写道
Post by Vadim Zeitlin
l> sorry, I don't quite understand the source code. In shaped sample code, I
l> just changed one line.
l>
l> SetShape(wxRegion(m_bmp, *wxWHITE)); --> SetShape(wxRegion(m_bmp,
l> *wxBLACK));
l>
l> and the window never showed up. I know the star.png doesn't have a pixel of
l> black color, but the reasonable result should be the window showing up
l> without any part hidden, right?
Why? If the region is empty, it seems normal to me that nothing is shown.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
On second thought, yes I agree. Could you be kind enough to take a look at
the png file for me? Here is my code:
m_bmp = wxBitmap(wxT("window.bmp"), wxBITMAP_TYPE_BMP );

wxColour color(48, 50, 140, 255);

SetShape(wxRegion(m_bmp, color));

I want to hide the color rgb(140, 50, 48) to make window round-cornered
but it doesn't work. Many thanks!!


Regards,

Leo
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-06-11 15:23:41 UTC
Permalink
On Wed, 11 Jun 2014 08:20:21 -0700 (PDT) leo.zhou wrote:

l> On second thought, yes I agree. Could you be kind enough to take a look at
l> the png file for me?

Sorry, as I said, I don't have time to look at this immediately. It really
shouldn't be that difficult to at least check whether the correct region is
created. And if you discover that this is what doesn't work, please try to
create a _small_ test bitmap and open a Trac ticket for it (although,
again, if you can try debugging this yourself, this would certainly help).

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Continue reading on narkive:
Loading...