2015-01-13 4 views
0

안녕하세요 저는 C++에 매우 익숙합니다. 나는 이미지를 회전하고 저장하는 위의 코드에 노력하고이미지를 C++로 회전하십시오.

Image im(L"C:\\Temp\\SnapShotOutput.jpg"); 
im.RotateFlip(Rotate90FlipNone); 
im.Save("SampleImage_rotated.jpg"); 

... 이 늘 .compile는 3 라인

'Gdiplus::Image::Save' : no overloaded function takes 1 arguments 

는 위의 오류를 준다 실패 작동합니다. 누구든지 나를 도울 수 있습니다.

답변

0

다른 매개 변수도 설정해야합니다. 코드는 here입니다.

Image image(L"C:\\Temp\\SnapShotOutput.jpg"); 
image.RotateFlip(Rotate90FlipNone); 

// Save the altered image as PNG 
CLSID pngClsid; 
GetEncoderClsid(L"image/png", &pngClsid); 
image.Save(L"SampleImage_rotated.png", &pngClsid, NULL); 

// Save the altered image as JPG 
CLSID jpegClsid; 
GetEncoderClsid(L"image/jpeg", &jpegClsid); 
image.Save(L"SampleImage_rotated.jpg", &jpegClsid, NULL); 

GetEncoderClsid 기능 here 정의된다

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 
} 
관련 문제