/// <summary> /// Creates a 1-bit depth bitmap object from a binary file /// </summary> /// <param name="widthinPixels">Width of the bitmap in pixels</param> /// <param name="heightinPixels">Height of the bitmap in pixels</param> /// <param name="filename">Filename containing the binary data defining the bitmap</param> protected void BuildBitmapResource(int widthinPixels, int heightinPixels, string filename) { using (var bmpfile = new FileStream(SdMountPoint + @"\" + filename, FileMode.Open, FileAccess.Read, FileShare.None)) { // Note: don't exceed the amount of RAM available in the netduino by loading files that are too large! // This will result in an out-of-memory exception. var bitmapdata = new byte[(int)bmpfile.Length]; bmpfile.Read(bitmapdata, 0, (int)bmpfile.Length); var bitmap = new Imaging.Bitmap(bitmapdata, widthinPixels, heightinPixels); Bitmaps.Add(filename, bitmap); } }
/// <summary> /// Creates a 1-bit depth bitmap object from a binary file /// </summary> /// <param name="widthinPixels">Width of the bitmap in pixels</param> /// <param name="heightinPixels">Height of the bitmap in pixels</param> /// <param name="filename">Filename containing the binary data defining the bitmap</param> protected void BuildBitmapResource(int widthinPixels, int heightinPixels, string filename) { using (var bmpfile = new FileStream(Path + @"\" + filename, FileMode.Open, FileAccess.Read, FileShare.None)) { // Note: don't exceed the amount of RAM available in the netduino by loading files that are too large! // This will result in an out-of-memory exception. var bitmapdata = new byte[(int) bmpfile.Length]; bmpfile.Read(bitmapdata, 0, (int) bmpfile.Length); var bitmap = new Imaging.Bitmap(bitmapdata, widthinPixels, heightinPixels); Bitmaps.Add(filename, bitmap); } }