This is a migrated thread and some comments may be shown as answers.

PictureBox BitmapImage/Embedded resource problems

1 Answer 287 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 22 Aug 2012, 07:41 AM

In a report I'm working on we want to display some images based on the value of a field. For that purpose I've created a UserFunction that grabs the image out of our embedded resource pack and returns it.

This is where things get a bit ugly.

Since this is a WPF app, we use BitmapImage for storing embedded image resources. It appears that the PictureBox doesn't support BitmapImage? The exception rendered in the Picturebox is "The given key was not present in the dictionary"

To avoid using BitmapImage I've tried returning the URI to the resource, also to no avail. The URI is prefixed with pack:// and that is apparently an unsupported prefix (according to the exception message.)

Going from BitmapImage to an  actual GDI+ Image is not trivial since we're running a WPF app and I would really like to avoid doing that. Physical paths are also not an option...

Any ideas?

1 Answer, 1 is accepted

Sort by
0
IvanY
Telerik team
answered on 23 Aug 2012, 01:51 PM
Hello Andreas,

Currently Telerik Reporting supports only formats that are supported by GDI+ (see PictureBox help article). In your case you will need to convert your image before using it. Converting BitmapImages to Jpeg for example is actually quite simple and can be done with few lines of code. Check this article that covers the conversion from BitmapImage to other formats. You may also want to have a look at the last snippet, where the BitmapImage is converted to Bitmap.

Regards,
IvanY
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
Andreas
Top achievements
Rank 1
Answers by
IvanY
Telerik team
Share this question
or