Jump to content

Help with HEX to JPEG Parameter invalid error!

CGameDev

I am writing a code to convert from hex value to a byte[] then to a jpg. I am getting Parameter invalid at my memory stream syntax. Can anyone help me with this please

/*Call function to Convert the hex data to byte array.*/
                            byte[] GetByte = SetByteArray(JPEG_HEX_DATA);
                            /*Creating memory stream for the byte array.*/
                            MemoryStream MEM_ST = new MemoryStream(GetByte);
                            /*Save the memory stream to file, result in a jpeg image.*/
                            try
                            {                                
                                /*Creating memory stream for the byte array.*/
                                Image JPEG = System.Drawing.Image.FromStream(MEM_ST);/*<- Parameter invalid error*/
                                /*Save the memory stream to file, result in a jpeg image.*/
                                JPEG.Save(ImgDestination.Text + "IMG" + JPG_COUNT + ".jpg");
                                /*Dispose of current image in stream.*/
                                MEM_ST.Dispose();                                                               
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK);
                            }

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×