Skip to main content
nguyens94075769
Known Participant
January 18, 2016
Question

Read tiff image file format by IImageReadFormat was not supported.

  • January 18, 2016
  • 0 replies
  • 262 views

I use IImageReadFormat to read width and height from file.

This my source code:

        InterfacePtr<IPMStream> fileStream(StreamUtil::CreateFileStreamRead(this->fSysFile));

        if (fileStream == nil)

        {

            break;

        }

        InterfacePtr<IImageFormatManager> iImageFormatManager(::CreateObject2<IImageFormatManager>(kImageFormatManager, IID_IIMAGEFORMATMANAGER));

        if (iImageFormatManager == nil)

            break;

        InterfacePtr<IImageReadFormat> iImageReadFormat(iImageFormatManager->QueryImageReadFormat(fileStream));

        if (iImageReadFormat == nil)

            break;

        InterfacePtr<IImageAttributes> iImageAttr(::CreateObject2<IImageAttributes>(kImageObject, IID_IIMAGEATTRIBUTES));

        if (iImageAttr == nil)

            break;

        if (iImageReadFormat->CanRead(fileStream) == kFalse)

            break;

        status = kTrue;

        iImageReadFormat->Open(fileStream);

        if (iImageReadFormat->GetImageAttributes(iImageAttr))

        {

              // Get width and height

        }

.....

with tiff image iImageReadFormat->GetImageAttributes(iImageAttr) return kFalse with warning message: "Error encountered while reading TIFF image. Image may be damaged or incompatible. Resave the image with different setting and try again".

Anyone has other way to get tiff image width and height from file? Many thanks.

This topic has been closed for replies.