how can i convert Json to image directly?
I tried to convert json to image directly, but I couldnt. how can I do it?
What I have tried:
Here is the json structure:
{"objects":[{"type":"text","originX":"left","originY":"top","left":15.87,"top":10.24,"width":491.24,"height":56.5,"fill":"#ffffff","stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,"scaleX":0.4,"scaleY":0.4,"angle":0,"flipX":false,"flipY":false,"opacity":1,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"text":"آغاز بارندگي = خطر لغزندگي","fontSize":"50","fontWeight":"","fontFamily":"B Titr","fontStyle":"normal","lineHeight":1,"underline":false,"overline":false,"linethrough":false,"textAlign":"left","textBackgroundColor":"","charSpacing":0,"styles":{}}],"background":"#000"}
And this is the code to convert:
Bitmap bm = new Bitmap(384, 80);
{
return false;
}
int i = 0;
App_Code.ImageConverter imgConverter = new App_Code.ImageConverter();
foreach (DataRow dr_VMS in dt_VMS.Rows)
{
try
{
var rootObject = Newtonsoft.Json.JsonConvert.DeserializeObject<App_Code.Rootobject>(dr_VMS["JasonForImageFile"].ToString());
if (rootObject.objects[0].type == "text")
{
Bitmap bm = new Bitmap(384, 80);
string image = dr_VMS["JasonForImageFile"].ToString();
byte[] byteBuffer = Convert.FromBase64String(image);
MemoryStream memoryStream = new MemoryStream(byteBuffer);
memoryStream.Position = 0;
bm = (Bitmap)Bitmap.FromStream(memoryStream);
}
}
catch
{ }
}
return true;