C++ builder 6 Image JPEG圖片註解

最近老師出了一個作業

要把JPEG所有的資訊讀出來 從 Width`,Height Phase...

還有一種叫 圖片註解 不知道 C++ builder6 IMAGE有什麼函數可以直接讀取呢?如果沒有 那要怎麼讀取?

Update:

JJ

出現了錯誤訊息

[C++ Error] GdiplusTypes.h(459): E2268 Call to undefined function 'min'

[C++ Error] GdiplusTypes.h(461): E2268 Call to undefined function 'max'

Update 2:

[C++ Warning] GdiplusHeaders.h(582): W8022 'Bitmap::Clone(const Rect &,int)' hides virtual function 'Image::Clone()'

[C++ Error] GdiplusGraphics.h(34): E2015 Ambiguity between 'Gdiplus::Graphics::Graphics(void *)' and 'Gdiplus::Graphics::Graphics(void *,int)'

Update 3:

是成功了 但是哪一個才是圖片註解呢?

2 Answers

Rating
  • 10 years ago
    Favorite Answer

    使用微軟定義的 Function :

    Gdiplus::Image

    圖片註解: http://msdn.microsoft.com/en-us/library/ms535372%2...

    Height:

    http://msdn.microsoft.com/en-us/library/ms535380%2...

    Width:

    http://msdn.microsoft.com/en-us/library/ms535397%2...

    #include <windows.h>

    #include <gdiplus.h>

    #include <stdio.h>

    using namespace Gdiplus;

    INT main()

    {

    GdiplusStartupInput gdiplusStartupInput;

    ULONG_PTR gdiplusToken;

    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

    // Create an Image object based on a JPEG file.

    Image* image = new Image(L"FakePhoto.jpg");

    // Find out how many property items are in the image, and find out the

    // required size of the buffer that will receive those property items.

    UINT totalBufferSize;

    UINT numProperties;

    image->GetPropertySize(&totalBufferSize, &numProperties);

    // Allocate the buffer that will receive the property items.

    PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);

    // Fill the buffer.

    image->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);

    // Print the id data member of each property item.

    for(UINT j = 0; j < numProperties; ++j)

    {

    printf("%x\n", pAllItems[j].id);

    }

    UINT imageHeight = image->GetHeight();

    printf("The height of the image is %u.\n", imageHeight);

    UINT imageWidth = image->GetWidth();

    printf("The width of the image is %u.\n", imageWidth);

    free(pAllItems);

    delete image;

    GdiplusShutdown(gdiplusToken);

    return 0;

    }

    2010-07-19 10:42:53 補充:

    the ID numbers in Gdiplusimaging.h.

    PropertyTagImageDescription

    Null-terminated character string that specifies the title of the image.

    Tag 0x010E

    Type PropertyTagTypeASCII

    Count Length of the string including the NULL terminator

    http://msdn.microsoft.com/en-us/library/ms534416%2...

    2010-07-19 15:17:44 補充:

    the following is the Tag IDs for common properties:

    9c9b = Title

    9c9c = Comment

    9c9d = Author

    9c9e = Keywords

    9c9f = Subject

Still have questions? Get your answers by asking now.