Saving a JPG from a BMP using GDI+ with a set DPI
<p>I have an image in BMP form and I want a C++ program to save it to JPG using GDI+, after reading some GDI+ documentation I came up with this program:</p>

<pre><code>#include &lt;windows.h&gt;
#include &lt;objidl.h&gt;
#include &lt;gdiplus.h&gt;
#include "GdiplusHelperFunctions.h"


#pragma comment (lib,"Gdiplus.lib")

VOID SaveFile()
{
    // Initialize GDI+.
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    GdiplusStartup(&amp;gdiplusToken, &amp;gdiplusStartupInput, NULL);

    CLSID   encoderClsid;
    Status  stat;
    EncoderParameters encoderParameters;
    ULONG    quality;
    Image*   image = new Gdiplus::Image(L"plot.bmp");

    // Get the CLSID of the PNG encoder.
    GetEncoderClsid(L"image/jpeg", &amp;encoderClsid);

    encoderParameters.Count = 1;
    encoderParameters.Parameter[0].Guid = EncoderQuality;
    encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
    encoderParameters.Parameter[0].NumberOfValues = 1;

    quality = 100;
    encoderParameters.Parameter[0].Value = &amp;quality;

    stat = image-&gt;Save(L"plot100.jpg", &amp;encoderClsid, &amp;encoderParameters);

    if (stat == Ok)
        printf("plot.jpg was saved successfully\n");
    else
        printf("Failure: stat = %d\n", stat);

    delete image;
     GdiplusShutdown(gdiplusToken);
    return;
}

int main()
{
    SaveFile();
    return 0;
}
</code></pre>

<p>But the image is saving with a horizontal and vertical resolution of 7dpi no matter what the value of "quelity" is, I need to save the jpg with a 96dpi, how can I set that?</p>

<p>Thank you in advance.</p>