wx.AlphaPixelData() is failing on windows server 2003

wx.AlphaPixelData() is failing on windows server 2003. The sample code
is given below.
The same is working fine on windows xp. what could be the reason?

import wx

class Size(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(250, 200))
        absFilename = "C:\Python26\Lib\site-packages\win32\Demos\images
\smiley.bmp"
        bmp = wx.Bitmap(absFilename, wx.BITMAP_TYPE_BMP)
        pixelData = wx.AlphaPixelData(bmp)

        if not pixelData:
            print "error"
        else:
            print "fine"

app = wx.App(False)
Size(None, -1, 'Test')
app.MainLoop()

Do you have a traceback? Which version of wx are you using?

···

On Mar 11, 12:20 am, Mohan <mohankumar.ma...@gmail.com> wrote:

wx.AlphaPixelData() is failing on windows server 2003. The sample code
is given below.
The same is working fine on windows xp. what could be the reason?

import wx

class Size(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(250, 200))
absFilename = "C:\Python26\Lib\site-packages\win32\Demos\images
\smiley.bmp"
bmp = wx.Bitmap(absFilename, wx.BITMAP_TYPE_BMP)
pixelData = wx.AlphaPixelData(bmp)

    if not pixelData:
        print &quot;error&quot;
    else:
        print &quot;fine&quot;

app = wx.App(False)
Size(None, -1, 'Test')
app.MainLoop()

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

What does bmp.GetDepth()return on each platform? What about bmp.HasAlpha()? The most likely reason for wx.AlphaPixelData to fail is if there is no alpha channel. In that case you should either be using wx.NativePixelData instead, or perhaps giving the bitmap an alpha channel by converting to a wx.Image, calling InitAlpha, and converting back to a wx.Bitmap.

···

On 3/10/10 10:20 PM, Mohan wrote:

wx.AlphaPixelData() is failing on windows server 2003. The sample code
is given below.
The same is working fine on windows xp. what could be the reason?

import wx

class Size(wx.Frame):
     def __init__(self, parent, id, title):
         wx.Frame.__init__(self, parent, id, title, size=(250, 200))
         absFilename = "C:\Python26\Lib\site-packages\win32\Demos\images
\smiley.bmp"
         bmp = wx.Bitmap(absFilename, wx.BITMAP_TYPE_BMP)
         pixelData = wx.AlphaPixelData(bmp)

         if not pixelData:
             print "error"
         else:
             print "fine"

app = wx.App(False)
Size(None, -1, 'Test')
app.MainLoop()

--
Robin Dunn
Software Craftsman

Hi,

bmp.GetDepth() returns 24 on local system.

The below error is getting generated for wx.ActivePixelData() on remote system and wx.NativePixelData() on local system.

File "C:\p4_qctp4061666_KUMARM-XP\source\qcom\qct\platform\brewmp\ui\mango\mai

n\latest\Tools\Atelier\trunk\Generate.py", line 382, in GenerateAllGroupwise

ret = _GenImageData(imgDict, project, pathPrefix)

File "C:\p4_qctp4061666_KUMARM-XP\source\qcom\qct\platform\brewmp\ui\mango\mai

n\latest\Tools\Atelier\trunk\Generate.py", line 1199, in _GenImageData

__WritePixelVals(bmp, f, hasAlpha)

File "C:\p4_qctp4061666_KUMARM-XP\source\qcom\qct\platform\brewmp\ui\mango\mai

n\latest\Tools\Atelier\trunk\Generate.py", line 1125, in __WritePixelVals

pixelData = wx.NativePixelData(bmp)

File “C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx_gdi.py”, line 966,

in init

_gdi_.NativePixelData_swiginit(self,_gdi_.new_NativePixelData(*args))

wx._core.PyAssertionError: C++ assertion “wxAssertFailure” failed at …..\src\m

sw\bitmap.cpp(1287) in wxBitmap::GetRawData(): incorrect bitmap type in wxBitmap

::GetRawData()

Regards,

Mohan Kumar

···

On Fri, Mar 12, 2010 at 12:00 AM, Robin Dunn robin@alldunn.com wrote:

On 3/10/10 10:20 PM, Mohan wrote:

wx.AlphaPixelData() is failing on windows server 2003. The sample code
is given below.
The same is working fine on windows xp. what could be the reason?

import wx

class Size(wx.Frame):
def init(self, parent, id, title):
wx.Frame.init(self, parent, id, title, size=(250, 200))
absFilename = "C:\Python26\Lib\site-packages\win32\Demos\images

\smiley.bmp"
bmp = wx.Bitmap(absFilename, wx.BITMAP_TYPE_BMP)
pixelData = wx.AlphaPixelData(bmp)

    if not pixelData:
        print "error"
    else:
        print "fine"

app = wx.App(False)
Size(None, -1, ‘Test’)
app.MainLoop()

What does bmp.GetDepth()return on each platform? What about bmp.HasAlpha()? The most likely reason for wx.AlphaPixelData to fail is if there is no alpha channel. In that case you should either be using wx.NativePixelData instead, or perhaps giving the bitmap an alpha channel by converting to a wx.Image, calling InitAlpha, and converting back to a wx.Bitmap.


Robin Dunn
Software Craftsman
http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Typing mistake: it is wx.AlphaPixelData() not wx.ActivePixelData()

···

On Mar 12, 3:29 pm, Mohan Kumar <mohankumar.ma...@gmail.com> wrote:

Hi,

bmp.GetDepth() returns 24 on local system.

The below error is getting generated for wx.ActivePixelData() on
remote system and wx.NativePixelData() on local system.

File
"C:\p4_qctp4061666_KUMARM-XP\source\qcom\qct\platform\brewmp\ui\mango\mai

n\latest\Tools\Atelier\trunk\Generate.py", line 382, in GenerateAllGroupwise

ret = \_GenImageData\(imgDict, project, pathPrefix\)

File
"C:\p4_qctp4061666_KUMARM-XP\source\qcom\qct\platform\brewmp\ui\mango\mai

n\latest\Tools\Atelier\trunk\Generate.py", line 1199, in _GenImageData

\_\_WritePixelVals\(bmp, f, hasAlpha\)

File
"C:\p4_qctp4061666_KUMARM-XP\source\qcom\qct\platform\brewmp\ui\mango\mai

n\latest\Tools\Atelier\trunk\Generate.py", line 1125, in __WritePixelVals

pixelData = wx\.NativePixelData\(bmp\)

File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py", line
966,

in __init__

\_gdi\_\.NativePixelData\_swiginit\(self,\_gdi\_\.new\_NativePixelData\(\*args\)\)

wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at
..\..\src\m

sw\bitmap.cpp(1287) in wxBitmap::GetRawData(): incorrect bitmap type in
wxBitmap

::GetRawData()

Regards,

Mohan Kumar

On Fri, Mar 12, 2010 at 12:00 AM, Robin Dunn <ro...@alldunn.com> wrote:
> On 3/10/10 10:20 PM, Mohan wrote:

>> wx.AlphaPixelData() is failing on windows server 2003. The sample code
>> is given below.
>> The same is working fine on windows xp. what could be the reason?

>> import wx

>> class Size(wx.Frame):
>> def __init__(self, parent, id, title):
>> wx.Frame.__init__(self, parent, id, title, size=(250, 200))
>> absFilename = "C:\Python26\Lib\site-packages\win32\Demos\images
>> \smiley.bmp"
>> bmp = wx.Bitmap(absFilename, wx.BITMAP_TYPE_BMP)
>> pixelData = wx.AlphaPixelData(bmp)

>> if not pixelData:
>> print "error"
>> else:
>> print "fine"

>> app = wx.App(False)
>> Size(None, -1, 'Test')
>> app.MainLoop()

> What does bmp.GetDepth()return on each platform? What about
> bmp.HasAlpha()? The most likely reason for wx.AlphaPixelData to fail is if
> there is no alpha channel. In that case you should either be using
> wx.NativePixelData instead, or perhaps giving the bitmap an alpha channel by
> converting to a wx.Image, calling InitAlpha, and converting back to a
> wx.Bitmap.

> --
> Robin Dunn
> Software Craftsman
>http://wxPython.org

> --
> To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com<wxPython-users%2Bunsubscribe@go­oglegroups.com>
> or visithttp://groups.google.com/group/wxPython-users?hl=en- Hide quoted text -

- Show quoted text -

That error is coming from this code:

     // check that the bitmap is in correct format
     if ( ds.dsBm.bmBitsPixel != bpp )
     {
         wxFAIL_MSG( _T("incorrect bitmap type in wxBitmap::GetRawData()") );

         return NULL;
     }

So again, the issue has to do with a bits per pixel mismatch between what you have and what your code is trying to use. If the depth is 24 then you need to use wx.NativePixelData, and if it's 32 then you need to use wx.AlphaPixelData. If there is still a problem then please provide a small runnable sample that demonstrates it. MakingSampleApps - wxPyWiki

···

On 3/12/10 2:29 AM, Mohan Kumar wrote:

Hi,

bmp.GetDepth() returns 24 on local system.

The below error is getting generated for wx.ActivePixelData() on
remote system and wx.NativePixelData() on local system.

   File
"C:\p4_qctp4061666_KUMARM-XP\source\qcom\qct\platform\brewmp\ui\mango\mai

n\latest\Tools\Atelier\trunk\Generate.py", line 382, in GenerateAllGroupwise

     ret = _GenImageData(imgDict, project, pathPrefix)

   File
"C:\p4_qctp4061666_KUMARM-XP\source\qcom\qct\platform\brewmp\ui\mango\mai

n\latest\Tools\Atelier\trunk\Generate.py", line 1199, in _GenImageData

     __WritePixelVals(bmp, f, hasAlpha)

   File
"C:\p4_qctp4061666_KUMARM-XP\source\qcom\qct\platform\brewmp\ui\mango\mai

n\latest\Tools\Atelier\trunk\Generate.py", line 1125, in __WritePixelVals

     pixelData = wx.NativePixelData(bmp)

   File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py",
line 966,

in __init__

     _gdi_.NativePixelData_swiginit(self,_gdi_.new_NativePixelData(*args))

wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at
..\..\src\m

sw\bitmap.cpp(1287) in wxBitmap::GetRawData(): incorrect bitmap type in
wxBitmap

::GetRawData()

--
Robin Dunn
Software Craftsman