These are chat archives for mono/monodevelop

10th
Jul 2017
Andres G. Aragoneses
@knocte
Jul 10 2017 02:41
lextm: what do you mean with "MD/XS was the past"?
Josik Dranyj
@Rombersoft
Jul 10 2017 08:53

Hello Guys! Buy Attention! mono 5. I work with pictures with jpeg format.
I need draw some logo over source image and tha save image to jpeg without compressing (high quality).
So my code:

        using(Image img = Image.FromStream(openFileDialog1.OpenFile())) //source image has size 298 000 bytes
        {
            using (MemoryStream memStream = new MemoryStream())
            {
                ImageCodecInfo jpegEncoder = GetEncoder(ImageFormat.Jpeg);
                System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;
                EncoderParameters myEncoderParameters = new EncoderParameters(1);
                EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L); //I can use 50L, 100L, 75L but it's not difference what number I direct - result is equal always
                myEncoderParameters.Param[0] = myEncoderParameter;
                img.Save(memStream, jpegEncoder, myEncoderParameters);
                byte[] buff = memStream.ToArray();
                Console.WriteLine("Size = {0}", buff.Length);          //result image has size 38 900 bytes
            }
        }

    private ImageCodecInfo GetEncoder(ImageFormat format)
    {
        ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
        foreach (ImageCodecInfo codec in codecs)
        {
            if (codec.FormatID == format.Guid)
            {
                return codec;
            }
        }
        return null;
    }

It's not difference what level quality I set, because result will be equal always. Result image is compressed with losing quality.
But in OS Windows it works excellent.
Maybe must I try a GTK-Sharp/Cairo for resolving this issue?

Alexander Jochum
@DarkCloud14
Jul 10 2017 19:54
@Rombersoft could be a bug or problem of Mono as not everything of System.Drawing is implemented in libgdiplus library.
You might try the following library instead but you must check if the license is ok for you: http://imagesharp.net/
Alexander Jochum
@DarkCloud14
Jul 10 2017 20:06
BTW addins.monodevelop.com has stopped working again... No builds of the build system, does somebody know if there will be a new build system or another way to distribute the addins so users can download them via addin/extension manager without adding another distribution site?? Also last time I checked it still had the wrong dll libraries for MD 7.0 which causes the stripping of System.Collections.Immutable library reference for my addin, more details can be found in my posts above....
Josik Dranyj
@Rombersoft
Jul 10 2017 21:04
I try to use gtk-sharp, especially pixbuf class. It saves without losing quality but least to understand how get pixbuf from context or gdkWindow