giggetto71 Active Member Licensed User Longtime User Apr 19, 2021 #1 Hi, I am successfully receiving and using images in B4J using B4X: Copy ........... If topic = "image" Then Dim in As InputStream in.InitializeFromBytesArray(Payload, 0, Payload.Length) Dim bmp As Image bmp.Initialize2(in) in.Close ImageView1.SetImage(bmp) ........... I was wondering. is there a way to check if the received bytes are an actual image or not? Does bmp.initialize2 return some kind of error if the inputstream is "just" a stream with no image content? thanks
Hi, I am successfully receiving and using images in B4J using B4X: Copy ........... If topic = "image" Then Dim in As InputStream in.InitializeFromBytesArray(Payload, 0, Payload.Length) Dim bmp As Image bmp.Initialize2(in) in.Close ImageView1.SetImage(bmp) ........... I was wondering. is there a way to check if the received bytes are an actual image or not? Does bmp.initialize2 return some kind of error if the inputstream is "just" a stream with no image content? thanks
Erel B4X founder Staff member Licensed User Longtime User Apr 19, 2021 #2 It will throw an error if the data is not a valid bitmap. You can catch it. Upvote 0