APPARENT **NASTY BUG** IN CF 2.0

G

Guest

I posted on this yesterday but did not get a response, so I'm trying again. I
would REALLY APPRECIATE IT if someone at Microsoft would comment on this, as
I am fairly sure that the problem is not just a manifestation of my innate
stupidity.

Searching the web produces much confirmation that Bitmap.Save was absent
from CF 1.0, that it was greatly missed, and that it was to be added in CF
2.0. Also, my VS 2005 beta 2 documentation indicates that Bitmap.Save is
supported in the CF. (Specifically, when I look up the Bitmap Members, and
click on Save, I am directed to a page titled "Image.Save" with various
overloads, including the following:

Image.Save(String,ImageFormat) Saves this Image object to the specified
file in the specified format. Supported by the .NET Compact Framwork.

When I look up ImageFormat's members, 4 have little handheld icons
associated with them: Bmp, Gif, Jpeg and Png. However, these do not have the
text "Supported by the .NET Compact Framework".

Now consider the following simple code:
MessageBox.Show(System.Environment.Version.ToString());
Bitmap bmp = new Bitmap(100, 100);
bmp.Save("bmp.jpg", ImageFormat.Jpeg);

When this is run on the desktop, of course no problem. When it is run on the
Pocket PC Magneto emulator that came with VS 2005 beta 2, the last line
produces the following exception:

"An unhandled exception of type 'System.NotSupportedException' occurred in
System.Drawing.dll. Additional information: NotSupportedException". The
first line displays the CF version, which is 2.0.5056.0."

Now, it turns out that the same problem occurs with ImageFormat.Gif and
ImageFormat.Png, as well as ImageFormat.Jpeg, but NOT with ImageFormat.Bmp.
Thus it seems that support was left out for all image formats other than Bmp.
Either this is a bug, or the documentation is wrong.

This is a significant problem for me. I could use PInvoke with the Imaging
API to save the images as jpeg. However, the problem is that I want to
encrypt them as they are saved. This should be easy with the C# API, as I
should be able to use Bitmap.Save(Stream, ImageFormat) with a CryptoStream,
but will be significantly more difficult if I have to do it in C++ Imaging
API with the CryptoAPI.

OK, this was a reasonably detailed bug report, if I say so myself. Could we
have a word from Microsoft as to what is going on here?

Thank you,

Matthew Fleming
 
N

Nick Randolph

Dermite

Just did a quick test with your code (which looks ok to me) in the RC1 build
I have for VS and I experience the same issue. I would say that this
"feature" is here to stay at this point for v2.0. I would suggest that this
goes forward as a recommendation for SP1 for the .NET CF v2.0 as I would
suggest that being able to save to jpg would be desirable for a number of
developers.

Nick
 
G

Guest

Thank you for this. I was wondering whether the problem might be fixed in RC1.

There was another response to my query, which for some reason has been
deleted from the thread. This indicated that it is likely to be a platform
issue, rather than a CF issue. That is, the Windows Mobile 5.0 Pocket PC
platform may not support writing JPEG's. In this case, it could not be done
in native code, e.g. with the Imaging API.

It would be nice if we could get some comment from Microsoft, so we would
really know what is going on.

If the problem is a CF limitation, rather than a platform limitation, I
could use a combination of the Imaging API and CryptoAPI, in native code.
Instead, I have assumed the other comment was correct, and that the platform
does not support JPEG writing. So, I am using the Independent JPEG Group's
library with the CryptoAPI, in native code.

dermite
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top