Main Site Documentation

Image source


#1

Hi,

how can I add the image source of an image? I only see a pink box on my display.
This is my window created by glide designer:




What does mean Alpha? I see it almost at each element.

Thanks!


#2

[em]Post deleted[/em]

Andre beat me to it


#3

and why??
I got your post in my e-mail. Thank you for the very useful information!!


#4

@ SB - If you put a thread on “Watch”, You will get e-mails for every post in that thread.


#5

I know and that’s ok.
I wanted to say James only that I have read what he posted because his entry is deleted.


#6

The reason that there is not a facility to include the image source as a part of the Window Descriptor is that by standard, the source is converted into Base64, so that it does not interfere with the parser. However, by doing this, would increase the amount of time each window will have to be parsed. First you need to locate it in the mark up, then you have to convert it from Base64, then you have to parse the header of the image data to determine what format the data is in and then convert it to a proper bitmap that can be displayed. This will show serious lag on most system if you switch between one active window and another.

However, bringing in the image from resources means the system is only responsible for determining image format and bitmap conversion.


#7

I saved a picture from the internet and added it to my resources but I don’t get a bitmap resource but a binary resource.(s.attachment).
Can’t I include this picture in my screen??
Attachment 2 does not work:
GHIElectronics.NETMF.Glide.UI.Image Kaffee1 = (GHIElectronics.NETMF.Glide.UI.Image)window.GetChildByName(“Kaffee1”);
Kaffee1 = Resources.GetBytes(Resources.BinaryResources.Kaffee1);
I understand the reason but how to solve this issue??


#8

@ SB - What format is the image in? It seems as though, since there is no extension showing, the resource manager believes it is a binary file, not an image file.


#9

I looked at properties and found:
JPEG-Bild (.jpg)
When I go to resources.resx --> Add Resource --> I can select Add existing file(that’s what I tried first) or NewImage. Here I can choose the type but then I have to draw a picture with the tools available.


#10

in vb you need something like

           kaffee1.Bitmap = New Bitmap(Resources.GetBytes(Resources.BinaryResources.WAPPEN), Bitmap.BitmapImageType.Jpeg)

so must be some similar in c#


#11

I tried it now with the code:

GHIElectronics.NETMF.Glide.UI.Image Kaffee1 = (GHIElectronics.NETMF.Glide.UI.Image)window.GetChildByName(“bild”);
Kaffee1.Bitmap = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Kaffee1), Bitmap.BitmapImageType.Jpeg);
Kaffee1.Invalidate();

My window:





What does mean the following error message:
A first chance exception of type ‘System.OutOfMemoryException’ occurred in mscorlib.dll
An unhandled exception of type ‘System.OutOfMemoryException’ occurred in mscorlib.dll

I get the error in file Resources.Designer.cs
internal static byte[] GetBytes(Resources.BinaryResources id)
{
return ((byte[])(Microsoft.SPOT.ResourceUtility.GetObject(ResourceManager, id)));
}


#12

@ SB - That would mean that the image data is either too large for the available memory or it could mean that the image is larger than about 750KB.


#13

The image was too large, you’re right.
Now I tried with a smaller file.
My code is:
GHIElectronics.NETMF.Glide.UI.Image Kaffee4 = (GHIElectronics.NETMF.Glide.UI.Image)window.GetChildByName(“bild”);
Kaffee4.Bitmap = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Kaffee4), Bitmap.BitmapImageType.Jpeg);
Kaffee4.Invalidate();
I don’t get an error but also don’t see the image on the screen. The rectangle is also not there.
What can be the reason??


#14

Try to invalidate the Parent Window to force it to invalidate and redraw the child controls.


#15

I tried it with
window.Invalidate();
but the same result (image not there). The text of textbox is changed and contains the symbol °.


#16

Perhaps you should post some code so someone can better help you solve the problem.


#17

[quote]GHIElectronics.NETMF.Glide.UI.Image Kaffee4 = (GHIElectronics.NETMF.Glide.UI.Image)window.GetChildByName(“bild”);
Kaffee4.Bitmap = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Kaffee4), Bitmap.BitmapImageType.Jpeg);
Kaffee4.Invalidate();
window:








[/quote]


#18

Kaffee1.Stretch = true;
was missing.
Now I see the image and the code is:
GHIElectronics.NETMF.Glide.UI.Image Kaffee1 = (GHIElectronics.NETMF.Glide.UI.Image)window.GetChildByName(“Kaffee_rechts_oben”);
Kaffee1.Bitmap = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Kaffee1), Bitmap.BitmapImageType.Jpeg);
Kaffee1.Stretch = true;
Kaffee1.Invalidate();


#19

Is there a way to load directly the picture from the resources I want to display?
Cant I add for example in the Glide window
…Alpha=“255” Bitmap=“Resources.GetBytes(Resources.BinaryResources.Kaffee2)” />
Why do I have to do this via
image_name.Bitmap = new Bitmap(…)