How can I pass TIFF image data to JUCE (which does not support TIFF)?

941 Views Asked by At

I am using learning gui programming using c++ JUCE library. That library have supports for image file format(png, jpg). But I wants to learn how can I use other file format for example tiff.

After google I got libtiff.

My question is what will be the accurate approach for displaying this. Should I need to convert .tiff file into jpeg/png from tiff for doing this.

But I think this will require double processing.

Can anyone explain the raw/native/basic image file format so that I need to convert all images into that type and use it directly.

As I find something in winAPI for dealing with images in which they use image data from file format.

It will be very helpful if someone can let me know the approach for handling images data and displaying it.

3

There are 3 best solutions below

0
On

Can anyone explain the raw/native/basic image file format so that I need to convert all images into that type and use it directly.

There is no "native" image file format, but RGB comes close (especially if you strip the headers to give just a Width×Height×Channels array of pixel values). You probably wouldn't want to use this for storing everything though as your buffers will be very large. Let your libraries handle storage.

It will be very helpful if someone can let me know the approach for handling images data and displaying it.

There is no "the" approach. C++ itself doesn't say anything about images, and there are loads of ways you can go about working with them. Your design will depend on your functional requirements specification and on what libraries you have available.

I am using learning gui programming using c++ JUCE library. That library have supports for image file format(png, jpg). But I wants to learn how can I use other file format for example tiff.

After google I got libtiff.

My question is what will be the accurate approach for displaying this. Should I need to convert .tiff file into jpeg/png from tiff for doing this.

But I think this will require double processing.

If you mean using libtiff to convert TIFF-format images to formats that JUCE supports, you're right in saying that this introduces an extra initial processing step. However, as far as you've said, it sounds like any possible performance hit through this will be vastly, wildly and hugely outweighed by the benefit of simplicity and clarity. So I'd just do that.

1
On

In order to do something like read *.tiff images and using them in an application build with the JUCE framework, I would suggest to create a new class derived from the base interface ImageFileFormat.

class MyTiffFormat : public ImageFileFormat
{
  private:
    MyTiffFormat( const MyTiffFormat& );
    MyTiffFormat& operator=( const MyTiffFormat& );

  public:
    MyTiffFormat();
    ~MyTiffformat();

    const String getFormatName();
    bool canUnderStand();
    Image decodeImage( InputStream& input );
    bool writeImageToStream( const Image& source, OuptputStream& dest );

};

Implementing the function "Image decodeImage( InputSTeram& input )" is the point were you need something like libtiff. In the JUCE source tree you will find the implementation for PNG and the other supported formats in the folder: \juce\src\gui\graphics\imaging

More information on extending JUCE features can be found in the JUCE user forum.

0
On

Juce works great with pngs, jpgs, and gifs (not animated), and they can be read from file, or even "compiled" with the BinaryBuilder.

For example to load it from compiled c++ with BinaryBuilder.

someImage = ImageFileFormat::loadFrom (AppResources::image_png, AppResources::image_pngSize);

Check out the doxygen docs, they are quite helpful. to compile your images with BinaryBuilder the syntax is:

./BinaryBuilder someFolder otherFolder ClassName