Forums

Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

Postby BrendanSimon » Thu May 26, 2011 6:44 pm

I'm using wx.NET and need to convert an System.Drawing.Bitmap to a wx.Bitmap. I have some serialization code (C#) supplied by a wx.net maintainer, but Cobra is having trouble resolving an enum (wx.BitmapType.wxBITMAP_TYPE_PNG)

Here is the original C# statement that has the issue.

wxBitmapFromFxBitmap = new Bitmap(new Image(bitmapBytes, BitmapType.Png));
or
wxBitmapFromFxBitmap = new wx.Bitmap(new wx.Image(bitmapBytes, wx.BitmapType.Png));

If I use BitmapType.Png, I get the following error.

Cannot find a definition for "png" in "BitmapType" whose type is "BitmapType". There are members with similar names including ".wxBITMAP_TYPE_PNG" and ".wxBITMAP_TYPE_PNG_RESOURCE".

I notice the wx.net documentation says the BitmapType enum has identifiers such as wxBITMAP_TYPE_PNG, etc. If I use BitmapType.wxBITMAP_TYPE_PNG, I get the follwoing error.

"wx.BitmapType" does not contain a definition for "WxBITMAP_TYPE_INVALID"
"wx.BitmapType" does not contain a definition for "WxBITMAP_TYPE_PNG"

I'm not sure why the INVALID identifier is being referenced. Also notice the "Wx" ... not "wx".

Is this a Cobra issue ??
How can I fix this issue ??

Thanks, Brendan.
BrendanSimon
 
Posts: 14
Location: Melbourne, Australia

Re: Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

Postby Charles » Thu May 26, 2011 10:54 pm

I'll be happy to take a closer look, but I need more info:

What op sys and version are you on? What version of Mono or .NET? Are you running the latest Cobra from source or the last release? Same for wx.NET?

In the mean time, you might use a "sharp string" to work around this problem. Cobra uses C# as it's back-end for various benefits. One of them is that you can include C# source strings wherever an expression is expected and they will be passed through. We try to avoid this as much as possible, but it's a nice escape hatch for when there is a problem. It would be something like (in Cobra):
wxBitmapFromFxBitmap = Bitmap(Image(bitmapBytes, sharp'BitmapType.Png'))


Let me know about your platform and if that workaround works for you.

Also, out of pure curiosity, what desktop platforms do you plan on running your wx.net app on?
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

Postby BrendanSimon » Thu May 26, 2011 11:11 pm

I'm using the Cobra release (2010-10-18) from the Downloads page. I'm using it on XP and also OS X (10.6).

I'm using wx.net 0.9.2 on XP. I'm using wx.net 0.8.0 on OS X (that's the latest binary build available).

I don't know any C# (apart from what I've learnt today !!), but I entered the code into Visual Studio (also learnt today) and it compiled ok, so it would point towards a Cobra issue.

The sharp string seems to make the Cobra compiler happy :)

Code: Select all
wxBitmapFromFxBitmap = Bitmap(Image(bitmapBytes, sharp'wx.BitmapType.wxBITMAP_TYPE_PNG'))


Thanks, Brendan.
BrendanSimon
 
Posts: 14
Location: Melbourne, Australia

Re: Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

Postby BrendanSimon » Fri May 27, 2011 1:08 am

My test application now works with Cobra :) :) :)
It would be interesting to know if the svn release has this issue already resolved.
BrendanSimon
 
Posts: 14
Location: Melbourne, Australia

Re: Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

Postby hopscc » Fri May 27, 2011 8:20 am

There was some incorrect behaviour with wxWidgets/wx.net that had a patch provided for it.
I vaguely recall it was around non recognition of some symbols similar to the problem you allude to

I don't recollect whether the changes went into the source tree and if so if it predated the current distribution release or not.

There's a description of some of the issue and an early porting procedure at
Porting wxWidgets (wx.NET) C# source file to cobra

Its entirely possible theres still some holes in the handling of names in this area.
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

Postby Charles » Fri May 27, 2011 9:29 am

So Brendan, it would be great if you installed Cobra from source and gave it a whirl. You'll get a much better Cobra anyway.

Does wx have a syntax highlighting editor? Does it look good on Mac? Just curious. 8-)
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

Postby BrendanSimon » Fri May 27, 2011 6:45 pm

The wx.net maintainer is currently making changes to make names more .Net compliant/friendly. Here is a message from the wx.net (or is that WX.Net) home page dated 7-Feb-2011.

The original goal of the wx.NET project has been to wrap the famous wxWidgets framework. Therefore, classes and enumerations bear names as similar to their origins in wxWidgets as possible. As a consequence, the names of classes and enumerations contradict widely accepted conventions in .NET. The coming release will try to change this as far as possible. The MS tool for .NET code analysis FxCop is currently used to guide this process. However, current users of wx.NET will have to prepare for releases with significantly changed names for style flags etc. I recently changed the name of the project from wx.NET to WX.Net (correct Pascal spelling) to stress the purpose to make WX.Net more .Net.


Example:
Code: Select all
wx.wxBITMAP_TYPE_PNG  =>  wx.BitmapType.Png


So hopefully the next release will work a lot better with Cobra :) I do note that the MS C# compiler didn't have any issues with the name, so I don't know if that means Cobra has an issue, or is more strict, or if MSCS is less strict ???

I will try the latest Cobra from sources when I get a chance and let you know how it goes :)
BrendanSimon
 
Posts: 14
Location: Melbourne, Australia

Re: Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

Postby BrendanSimon » Fri May 27, 2011 6:53 pm

Got the latest Cobra sources from svn trunk and built/installed.
I got the same error (without using the sharp string) :(
Cheers, Brendan.
BrendanSimon
 
Posts: 14
Location: Melbourne, Australia

Re: Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

Postby Charles » Mon May 30, 2011 11:35 pm

I poked around the Cobra project tickets and wiki and didn't find any outstanding patch for wx. As hops said, this could be an additional case. I did manage to create an isolated test case for the situation you described and was able to trigger the bug (which I consider this to be). I don't have an ETA, but I'll fix this.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Can't resolve wx.Bitmap.wxBITMAP_TYPE_PNG

Postby Charles » Mon Jul 11, 2011 7:55 pm

This is fixed now. Combined with @help and the info on the wiki, you should be able to write wx apps now.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 30 guests