question

AhmedWassimBENSALEMENISo-3626 avatar image
0 Votes"
AhmedWassimBENSALEMENISo-3626 asked cooldadtx commented

*System.PlatformNotSupportedException:** 'Operation is not supported on this platform.'

Hello Guys ,
So i tried to run this game in xamarin forms ,
but when i try compile : System.Drawing.Bitmap mybitmap = new System.Drawing.Bitmap(img2); it raise that exception does anyone know what is the problem ?



90403-capture.png


dotnet-csharpdotnet-xamarin
capture.png (19.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

cooldadtx avatar image
0 Votes"
cooldadtx answered cooldadtx commented

The docs say that the value you're passing is is either not a valid image format or null. So what type of image is image? Why are you typecasting it to a byte array earlier in the code?

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @cooldadtx
the type of image is Object
This is the head of the method



90327-capture.png


0 Votes 0 ·
capture.png (3.9 KiB)
cooldadtx avatar image cooldadtx AhmedWassimBENSALEMENISo-3626 ·

That is just a placeholder type. You need to actually look at what is being passed in. It must be a byte array that contains a valid image otherwise you cannot convert it.

//Will fail
TakePhoto(10);

//Will work
TakePhoto(Image.FromFIle(""));

//Will only work if array came from an image
TakePhoto(imageArray);

You can do typechecking to some degree but there is no way to confirm a byte[] is an image without trying to convert.

if (image is byte[] arr)
//try to convert to image

0 Votes 0 ·

Okay So if the image is byte[] arr how can i convert it to system.drawing.Image ?

0 Votes 0 ·
Show more comments