Click here to Skip to main content
15,911,711 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Monitor Resolution problem............ Pin
Hamid_RT24-Nov-08 20:58
Hamid_RT24-Nov-08 20:58 
AnswerRe: Monitor Resolution problem............ Pin
Code-o-mat24-Nov-08 21:48
Code-o-mat24-Nov-08 21:48 
GeneralRe: Monitor Resolution problem............ Pin
CPallini24-Nov-08 23:29
mveCPallini24-Nov-08 23:29 
QuestionHow to convert image file *.pcx image into *.jpg image format. Pin
Member 462021624-Nov-08 19:42
Member 462021624-Nov-08 19:42 
AnswerRe: How to convert image file *.pcx image into *.jpg image format. Pin
Hamid_RT24-Nov-08 20:21
Hamid_RT24-Nov-08 20:21 
GeneralRe: How to convert image file *.pcx image into *.jpg image format. Pin
Member 462021624-Nov-08 21:22
Member 462021624-Nov-08 21:22 
GeneralRe: How to convert image file *.pcx image into *.jpg image format. Pin
enhzflep24-Nov-08 21:37
enhzflep24-Nov-08 21:37 
AnswerRe: How to convert image file *.pcx image into *.jpg image format. Pin
Mark Salsbery25-Nov-08 9:09
Mark Salsbery25-Nov-08 9:09 
Here's a way using GDI+...
#include <gdiplus.h>
...
    BITMAPINFO *pBitmapInfo = ...;
    BYTE *pBitmapPixelBits = ...;
    ULONG dwToken;
    Gdiplus::GdiplusStartupInput input;
    Gdiplus::GdiplusStartupOutput output;
    Gdiplus::Status status = Gdiplus::GdiplusStartup(&dwToken, &input, &output);
    if(status == Gdiplus::Ok)
    {
        Gdiplus::Bitmap bitmap(pBitmapInfo, pBitmapPixelBits);
        CLSID clsid;
        GetEncoderClsid(L"image/jpeg", &clsid);
        bitmap.Save(L"c:\\my.jpg", &clsid);

        Gdiplus::GdiplusShutdown(dwToken);
    }

...

// stolen from the GDI+ docs
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
}

If you can use ATL, the CImage class would allow you to do the same in a few lines of code.

Mark

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

Questionparent window is getting closed once child window is closed, how to keep parent dialog box alive? Pin
puppya24-Nov-08 19:14
puppya24-Nov-08 19:14 
AnswerRe: parent window is getting closed once child window is closed, how to keep parent dialog box alive? Pin
Hamid_RT24-Nov-08 19:29
Hamid_RT24-Nov-08 19:29 
GeneralRe: parent window is getting closed once child window is closed, how to keep parent dialog box alive? Pin
puppya24-Nov-08 19:30
puppya24-Nov-08 19:30 
GeneralRe: parent window is getting closed once child window is closed, how to keep parent dialog box alive? Pin
sheshidar24-Nov-08 22:07
sheshidar24-Nov-08 22:07 
QuestionFunctions not accessible in the new version of some .lib file Pin
SanjaySMK24-Nov-08 18:54
SanjaySMK24-Nov-08 18:54 
QuestionConverting .Mak Project to .sln project Pin
NiceNaidu24-Nov-08 18:31
NiceNaidu24-Nov-08 18:31 
Questionhelp me out Pin
ramina sen24-Nov-08 18:25
ramina sen24-Nov-08 18:25 
AnswerRe: help me out Pin
enhzflep24-Nov-08 18:53
enhzflep24-Nov-08 18:53 
AnswerRe: help me out Pin
Hamid_RT24-Nov-08 19:26
Hamid_RT24-Nov-08 19:26 
AnswerRe: help me out Pin
ramina sen24-Nov-08 19:33
ramina sen24-Nov-08 19:33 
GeneralRe: help me out Pin
Hamid_RT24-Nov-08 20:29
Hamid_RT24-Nov-08 20:29 
QuestionSHGetFileInfo Problem Pin
john563224-Nov-08 18:24
john563224-Nov-08 18:24 
AnswerRe: SHGetFileInfo Problem Pin
john563224-Nov-08 18:41
john563224-Nov-08 18:41 
QuestionRe: SHGetFileInfo Problem Pin
David Crow25-Nov-08 14:35
David Crow25-Nov-08 14:35 
QuestionHow to avoid memory leakage due to wglUseFontBitmaps(); Pin
anjanarakesh24-Nov-08 18:08
anjanarakesh24-Nov-08 18:08 
QuestionWhere is my form, and what is it? Pin
regnwald24-Nov-08 17:04
regnwald24-Nov-08 17:04 
AnswerRe: Where is my form, and what is it? Pin
Chandrasekharan P24-Nov-08 17:15
Chandrasekharan P24-Nov-08 17:15 

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.