Image from resource |
Post Reply |
Author | |
BobWansink
Groupie Joined: 24 January 2008 Status: Offline Points: 59 |
Post Options
Thanks(0)
Posted: 05 January 2009 at 8:59am |
Hi everyone,
first off, I would like to wish everyone here a happy new year. on to more serious matters: I'm trying to use XAML with localised dll's. These localised dll's contain my XAML resources. I also want it to contain the images i use in the XAML. Currently, I can't seem to make the images visible, even if I add complete, or relative paths to them in the code eg: <Image Source="file://somePicture.png"/> I would like it best if I could add the images to my localised DLL. That way, my customers wouldn't be able to replace, remove or rename the images on their hard drive. They would just get one dll (resources.dll) which would contain all the necessary files and code. In your manual it says: Loading Images Using XAML:Images stored in a ImageManager control: To reference an image stored in the ImageManager control, simply set "Source" attribute of an Image element to the id of the image to load. Note for this example there is an image with id "101" in the ImageManager control. Is there a way to load the images from my localised dll into the imagemanager? How do i do it? Is there an example? I've tried to look it up in the samples, but came out empty handed.I wouldn't mind if the images were loaded from the application resources by the way. I just don't want my customers to be able to "change" the images in any way. (I don't even want them to be aware of them...) Thanks a million, Bob |
|
Product: Xtreme ToolkitPro (MFC) version 13.0.0
Platform: Windows (32bit) - XP - Vista Language: Visual C++ |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
You can use "res://"
<Image Source="res://#100"/>
but image have to be located in main exe.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
BobWansink
Groupie Joined: 24 January 2008 Status: Offline Points: 59 |
Post Options
Thanks(0)
|
Thanks oleg,
adding the resources to the main application won't be a problem. Great! Bob |
|
Product: Xtreme ToolkitPro (MFC) version 13.0.0
Platform: Windows (32bit) - XP - Vista Language: Visual C++ |
|
JerryEvans
Groupie Joined: 01 May 2008 Location: United Kingdom Status: Offline Points: 39 |
Post Options
Thanks(0)
|
Oleg:
Your example implies that #100 is the bitmap ID - should this equate to a declaration in an RC file like this: GLYPH.BMP BITMAP "res\\glyph.bmp" Are any other file formats are supported? PNG or JPG? What about an image stored in the RC_DATA section? For example: EXCLAMATION.PNG RCDATA DISCARDABLE "res\\exclamation.png" Thanks Jerry |
|
JerryEvans
Groupie Joined: 01 May 2008 Location: United Kingdom Status: Offline Points: 39 |
Post Options
Thanks(0)
|
OK, I've done a bit of code sleuthing in the interim
The markup parser will load a PNG file from a resource if the _XTP_INCLUDE_GRAPHICLIBRARY macro has been defined. See XTPImageManager.cpp in the \common folder. I believe that the loader maintains any alpha channel in the PNG image - i.e it understands 32bit PNG files as well as 24bit varieties. This is excellent, well done team. The syntax for the resource file as follows. (I stored these in the RC2 file generated by a VC++ project) LOGO PNG DISCARDABLE "res\\nova-logo-320.png" or 100 PNG DISCARDABLE "res\\nova-logo-320.png" In the first case the XAML code should be: <Image Source="res://LOGO"/> and to load up the second the XAML should be <Image Source="res://#100"/> HTH someone else. Jerry |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |