How can I clone a FileStream type?

How can I clone a FileStream type?

The problem is what I use MagickNet.Image(inputStream)to get stretch images before saving, but it seems to close the input stream.

So, I can send a clone of the inputStream function to the function, so the function cannot edit the real inputStream object?

This is my function:

public Picture GetPictureDimension(Stream inputStream, Picture picture)
{
    var img = new MagickNet.Image(inputStream);

    picture.Width = img.Columns;
    picture.Height = img.Rows;

    return picture;
}
+3
source share
2 answers

Can you just re-open the file? But to save one Streamwithout closing, you can try NonClosingStreamWrapperin MiscUtil . Just be sure to reset Positionif necessary.

+2
source

, , MagickNet.Image(inputStream) , , .

, . .

:

, , , , ( ). , .

- XNA, ? , - :

public Picture GetPictureDimension(Stream inputStream, ref Picture picture)
{
    var img = new MagickNet.Image(inputStream);

    picture = new Picture(img);  // just guessing here
    //picture.Width = img.Columns;
    //picture.Height = img.Rows;

    return picture;
}
+1

Source: https://habr.com/ru/post/1733797/


All Articles