I have a program that I am writing that has many, many JPG images (269 to be exact). Rather than try to load these as resources, I opted to just load them on my SD card. What is the best way to display them on the LCD?
I figured it out!
// Create a file stream object FileStream fHandle = new FileStream(@ "\SD\WX_Icons\someico.jpg", FileMode.Open, FileAccess.Read); // Create the byte array to hold the data byte data = new byte[fHandle.Length]; // Copy the file data to the byte array fHandle.Read(data, 0, data.Length); // We're done. fHandle.Close(); Bitmap wxIcon = new Bitmap(data, Bitmap.BitmapImageType.Jpeg); Image wxi = new Image(wxIcon);
Works just great!
Well, that’s weird. It worked once, and now all I get is CLR_E_FILE_NOT_FOUND. I even confirmed that the file was on there.
I think I found a bug. Sometimes this works, sometimes it doesn’t.
We would need more details and a way for us to reproduce the problem on our end.
Hi Gus, I am going to send you an email… I was too tired to do it last night.
Sorry to dust off an old topic, but I had a quick question.
I’m back working on my Cobra NVR project and doing a lot with displaying, saving, and loading jpg’s. A common problem I’m running into is the usual out of memory error when trying to move a jpg into a byte array, because once unpacked, the jpg becomes quite a large image.
I’m just wondering if you’ve run into this as well and might have found a clever way to manage this.
Right now I’m working with jpg’s of about 260KB and am hitting the error (1600x1200). If I use something smaller, on the order of 20KB (320x240), I have no problem.
Thanks, and I hope things are going well!
My Photo Frame project on the project wiki does this. I also handles determining the Bitmap Type automatically based on the file extension. I also ran into problems when the image was not very small … I had to resize them all to be no more than the resolution of my device. Until I did that, every other image load would throw a memory allocation error even though I had plenty of free memory for the image. Tried forcing a GC and that didn’t help either.
Very nice project!
And here is the link to your project:
Hello all. First off I’m new to this fourm and to C# so i am going to ask a lot of dumb questions, so please excuse me. I have a Fez spider with a t35 display and SD card module. I have been researching and trying everything I can to get a image to display on my screen. I can get the text to show but I can’t seem to get the code correct. I am not having any trouble getting the SD card to mount or reading the files in output. Does anyone know the commands to display the image please?
Just load it to a bitmap and .Flush() the bitmap to screen if its the exact size of the screen. Otherwise you need to draw it onto another bitmap that is the same size and flush that one.