0

enter image description here

This is what happens when I load my project file into my software. This happens when I convert the 'byte' parameter into image again.

Here's my conversion method:

public Bitmap ConverToImage(byte[] ImageByteArray)
    {
        using (MemoryStream stream = new MemoryStream(ImageByteArray))
        {
            return (Bitmap)Image.FromStream(stream);
        }
    }

Pushing the byte into an object of the ImageClass

var image = new LayerClass
                        {
                            rect = l.rect,
                            image = img.ConverToImage(l.imageByte),
                            type = (LayerClass.Type)System.Enum.Parse(typeof(LayerClass.Type), "Image"),
                        };

Help.

TerribleDog
  • 1,237
  • 1
  • 8
  • 31
  • The answer is no `Resolution is broken when converting byte to image?` does not process or change your image in anyway, however what you do with it how you display it may lead you to this conclusion – TheGeneral Oct 23 '18 at 07:38
  • @TheGeneral I updated the question, that is how I use the byte into loading the image – TerribleDog Oct 23 '18 at 07:43
  • 1
    Define "resolution is broken". What exactly are we seeing here? What is the problem? – CodeCaster Oct 23 '18 at 08:39
  • the distorted picture in the bottom left should be a ribbon @CodeCaster – TerribleDog Oct 23 '18 at 09:37
  • The problem probably is in how you _save_ the image. Looks like transparency isn't supported by the format you chose. – CodeCaster Oct 23 '18 at 09:39
  • @CodeCaster I save it from image to byte then loads it the opposite way. What could go wrong? – TerribleDog Oct 23 '18 at 23:50
  • `Image.FromStream` **requires the stream to remain open for the life time of the image**. Meaning, you can't put it in a `using` block and return the image; you'll return an already-corrupted image. [Here's](https://stackoverflow.com/questions/49610796/picture-is-used-by-another-process-layoutpanel/49623930#49623930) a basic list of things to keep in mind when handling images. – Nyerguds Nov 13 '18 at 14:29

0 Answers0