//saves an a byte array as an image to the assets folder //Returns: format is image or not private bool CheckAndSaveBytesToAssets(byte[] rawBytes, long id) { if (ImageDecoding.GetImageFormat(rawBytes) != ImageDecoding.ImageFormat.unknown) { string filePath = Helper.GetRelativePath() + "/assets/" + id + ".png"; File.WriteAllBytes(filePath, rawBytes); return(true); } return(false); }
private bool CheckSaveAndSetPreview(byte[] rawBytes) { if (ImageDecoding.GetImageFormat(rawBytes) != ImageDecoding.ImageFormat.unknown) { //this.ImagePreview.Image = Bitmap.FromStream(stream); string filePath = Helper.GetRelativePath() + "/cache/preview.png"; File.WriteAllBytes(filePath, rawBytes); this.ImagePreview.ImageLocation = filePath; return(true); } return(false); }