Click here to Skip to main content
15,895,462 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionreceive(socket) before send(socket) Pin
nhathoang25-Oct-07 11:42
nhathoang25-Oct-07 11:42 
Questiona windows API function to convert JPG into BMP [modified] Pin
V_shr25-Oct-07 10:21
V_shr25-Oct-07 10:21 
AnswerRe: an API to convert JPG to BMP Pin
Chris Losinger25-Oct-07 10:23
professionalChris Losinger25-Oct-07 10:23 
GeneralRe: an API to convert JPG to BMP Pin
V_shr25-Oct-07 10:26
V_shr25-Oct-07 10:26 
GeneralRe: an API to convert JPG to BMP [modified] Pin
V_shr25-Oct-07 10:31
V_shr25-Oct-07 10:31 
AnswerRe: a windows API function to convert JPG into BMP Pin
Mark Salsbery25-Oct-07 11:09
Mark Salsbery25-Oct-07 11:09 
GeneralRe: a windows API function to convert JPG into BMP [modified] Pin
V_shr25-Oct-07 11:19
V_shr25-Oct-07 11:19 
GeneralRe: a windows API function to convert JPG into BMP Pin
Mark Salsbery25-Oct-07 11:27
Mark Salsbery25-Oct-07 11:27 
V_shr wrote:
CImage is a new class included with VC7 i think, but i dont use VisualStudio.NET


D'Oh! | :doh:

Ok, try this ...
    ULONG dwToken;
    Gdiplus::GdiplusStartupInput input;
    Gdiplus::GdiplusStartupOutput output;
    Gdiplus::Status status = Gdiplus::GdiplusStartup(&dwToken, &input, &output);
    if(status == Gdiplus::Ok)
    {
        Gdiplus::Bitmap *pBitmap = new Gdiplus::Bitmap(L"c:\\some.jpg", FALSE);
        CLSID bmpClsid;
        GetEncoderClsid(L"image/bmp", &bmpClsid);
        pBitmap->Save(L"c:\\some.bmp", &bmpClsid);
        delete pBitmap;

        Gdiplus::GdiplusShutdown(dwToken);
    }

I took the GetEncoderClsId() function right from the GDI+ docs in the Platform SDK.
It looks like this:
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
    UINT  num = 0;          // number of image encoders
    UINT  size = 0;         // size of the image encoder array in bytes

    ImageCodecInfo* pImageCodecInfo = NULL;

    GetImageEncodersSize(&num, &size);
    if(size == 0)
        return -1;  // Failure

    pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
    if(pImageCodecInfo == NULL)
        return -1;  // Failure

    GetImageEncoders(num, size, pImageCodecInfo);

    for(UINT j = 0; j < num; ++j)
    {
        if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
        {
            *pClsid = pImageCodecInfo[j].Clsid;
            free(pImageCodecInfo);
            return j;  // Success
        }    
    }

    free(pImageCodecInfo);
    return -1;  // Failure
}

Mark



Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: a windows API function to convert JPG into BMP Pin
V_shr25-Oct-07 11:31
V_shr25-Oct-07 11:31 
AnswerRe: a windows API function to convert JPG into BMP Pin
Paresh Chitte25-Oct-07 18:33
Paresh Chitte25-Oct-07 18:33 
QuestionEmpty array problem?! how to know if array empty or not? [modified] Pin
Gofur Halmurat25-Oct-07 9:51
Gofur Halmurat25-Oct-07 9:51 
AnswerRe: Empty array problem?! how to know if array empty or not? Pin
Jonathan [Darka]25-Oct-07 10:00
professionalJonathan [Darka]25-Oct-07 10:00 
GeneralRe: Empty array problem?! how to know if array empty or not? Pin
Gofur Halmurat25-Oct-07 10:02
Gofur Halmurat25-Oct-07 10:02 
GeneralRe: Empty array problem?! how to know if array empty or not? Pin
Mark Salsbery25-Oct-07 10:09
Mark Salsbery25-Oct-07 10:09 
GeneralRe: Empty array problem?! how to know if array empty or not? Pin
Jonathan [Darka]25-Oct-07 10:15
professionalJonathan [Darka]25-Oct-07 10:15 
AnswerRe: Empty array problem?! how to know if array empty or not? Pin
Mark Salsbery25-Oct-07 10:05
Mark Salsbery25-Oct-07 10:05 
GeneralRe: Empty array problem?! how to know if array empty or not? Pin
Gofur Halmurat25-Oct-07 10:09
Gofur Halmurat25-Oct-07 10:09 
AnswerRe: Empty array problem?! how to know if array empty or not? Pin
S_Murali25-Oct-07 20:12
S_Murali25-Oct-07 20:12 
QuestionLoad a resource script Pin
Demian Panello25-Oct-07 7:50
Demian Panello25-Oct-07 7:50 
AnswerRe: Load a resource script Pin
Mattias G25-Oct-07 8:39
Mattias G25-Oct-07 8:39 
GeneralRe: Load a resource script Pin
Demian Panello25-Oct-07 9:13
Demian Panello25-Oct-07 9:13 
GeneralRe: Load a resource script Pin
Mattias G25-Oct-07 10:12
Mattias G25-Oct-07 10:12 
GeneralRe: Load a resource script Pin
Demian Panello25-Oct-07 10:27
Demian Panello25-Oct-07 10:27 
Questionin order read using ifstream, i have to add ofstream after than do not know why??? Pin
kreena25-Oct-07 6:58
kreena25-Oct-07 6:58 
QuestionUsing XML in MFC Pin
LCI25-Oct-07 6:54
LCI25-Oct-07 6:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.