Hello!
(I am french)
if I resize an picture and I save it I can not read the file.
/*
picture = Camera picture
storage = sdCard.GetStorageDevice();
s_file = @ "db\img\img001.bmp"
s_file2 = @ "db\img_min\img001.bmp"
*/
try
{
Debug.Print("Save picture...");
storage.WriteFile(s_file, picture.PictureData);
Debug.Print("resize picture ...");
Bitmap b = utile.Divsize(picture.MakeBitmap());
Debug.Print("Save picture resize ...");
storage.WriteFile(s_file2, b.GetBitmap());
Debug.Print("Display picture resize ...");
display_T35.SimpleGraphics.DisplayImage(b, 0, 0);// It is ok
Debug.Print("load fill ...");
byte[] _byte = storage.ReadFile(s_file2);
Debug.Print("convert fill to picture...");
Bitmap b2 = new Bitmap(_byte, Bitmap.BitmapImageType.Bmp);// I have try all Type
Debug.Print("display picture loaded...");
display_T35.SimpleGraphics.DisplayImage(b2, 0, 50);
Debug.Print("end save and test...");
led.TurnBlue();
}
catch (Exception ex)
{
Debug.Print("Erreur dans la sauvgarde ");
Debug.Print("Message: " + ex.Message + " Inner Exception: " + ex.InnerException);
led.TurnRed();
}
public static Bitmap Divsize(Bitmap originale)
{
uint D = 5;
Bitmap sortie = new Bitmap(64, 48);
for (int y = 0; y < sortie.Height; y++)
{
for (int x = 0; x < sortie.Width; x++)
{
sortie.SetPixel(x, y, originale.GetPixel((int)(x * D), (int)(y * D)));
}
}
return sortie;
}
Save picture...
resize picture ...
Save picture resize ...
Display picture resize ...
load fill ...
convert fill to picture...
#### Exception System.Exception - CLR_E_FAIL (9) ####
#### Message:
#### Microsoft.SPOT.Bitmap::.ctor [IP: 0000] ####
#### Project_V1._0._2.Program::save_laste_picture [IP: 0206] ####
Une exception de première chance de type 'System.Exception' s'est produite dans Microsoft.SPOT.Graphics.dll
Erreur dans la sauvgarde
Message: Exception was thrown: System.Exception Inner Exception:
Le thread '<Sans nom>' (0x9) s'est arrêté avec le code 0 (0x0).
when I look the file in the SD card with my pc:
-> The original image is ok
-> The resize image is not readable