Blame IlmImf/ImfPreviewImage.h

Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
//
Packit 0d464f
// Copyright (c) 2003, Industrial Light & Magic, a division of Lucas
Packit 0d464f
// Digital Ltd. LLC
Packit 0d464f
// 
Packit 0d464f
// All rights reserved.
Packit 0d464f
// 
Packit 0d464f
// Redistribution and use in source and binary forms, with or without
Packit 0d464f
// modification, are permitted provided that the following conditions are
Packit 0d464f
// met:
Packit 0d464f
// *       Redistributions of source code must retain the above copyright
Packit 0d464f
// notice, this list of conditions and the following disclaimer.
Packit 0d464f
// *       Redistributions in binary form must reproduce the above
Packit 0d464f
// copyright notice, this list of conditions and the following disclaimer
Packit 0d464f
// in the documentation and/or other materials provided with the
Packit 0d464f
// distribution.
Packit 0d464f
// *       Neither the name of Industrial Light & Magic nor the names of
Packit 0d464f
// its contributors may be used to endorse or promote products derived
Packit 0d464f
// from this software without specific prior written permission. 
Packit 0d464f
// 
Packit 0d464f
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 0d464f
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 0d464f
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 0d464f
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 0d464f
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 0d464f
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 0d464f
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 0d464f
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 0d464f
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 0d464f
//
Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
Packit 0d464f
Packit 0d464f
#ifndef INCLUDED_IMF_PREVIEW_IMAGE_H
Packit 0d464f
#define INCLUDED_IMF_PREVIEW_IMAGE_H
Packit 0d464f
Packit 0d464f
#include "ImfNamespace.h"
Packit 0d464f
#include "ImfExport.h"
Packit 0d464f
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
//
Packit 0d464f
//	class PreviewImage -- a usually small, low-dynamic range image,
Packit 0d464f
//	that is intended to be stored in an image file's header.
Packit 0d464f
//
Packit 0d464f
//	struct PreviewRgba -- holds the value of a PreviewImage pixel.
Packit 0d464f
//
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Packit 0d464f
Packit 0d464f
Packit 0d464f
struct IMF_EXPORT PreviewRgba
Packit 0d464f
{
Packit 0d464f
    unsigned char	r;	// Red, green and blue components of
Packit 0d464f
    unsigned char	g;	// the pixel's color; intensity is
Packit 0d464f
    unsigned char	b;	// proportional to pow (x/255, 2.2),
Packit 0d464f
    				// where x is r, g, or b.
Packit 0d464f
Packit 0d464f
    unsigned char	a;	// The pixel's alpha; 0 == transparent,
Packit 0d464f
				// 255 == opaque.
Packit 0d464f
Packit 0d464f
    PreviewRgba (unsigned char r = 0,
Packit 0d464f
		 unsigned char g = 0,
Packit 0d464f
		 unsigned char b = 0,
Packit 0d464f
		 unsigned char a = 255)
Packit 0d464f
	: r(r), g(g), b(b), a(a) {}
Packit 0d464f
};
Packit 0d464f
Packit 0d464f
Packit 0d464f
class IMF_EXPORT PreviewImage
Packit 0d464f
{
Packit 0d464f
  public:
Packit 0d464f
Packit 0d464f
    //--------------------------------------------------------------------
Packit 0d464f
    // Constructor:
Packit 0d464f
    //
Packit 0d464f
    // PreviewImage(w,h,p) constructs a preview image with w by h pixels
Packit 0d464f
    // whose initial values are specified in pixel array p.  The x and y
Packit 0d464f
    // coordinates of the pixels in p go from 0 to w-1, and from 0 to h-1.
Packit 0d464f
    // The pixel with coordinates (x, y) is at address p + y*w + x.
Packit 0d464f
    // Pixel (0, 0) is in the upper left corner of the preview image.
Packit 0d464f
    // If p is zero, the pixels in the preview image are initialized with
Packit 0d464f
    // (r = 0, b = 0, g = 0, a = 255).
Packit 0d464f
    //
Packit 0d464f
    //--------------------------------------------------------------------
Packit 0d464f
   
Packit 0d464f
     PreviewImage (unsigned int width = 0,
Packit 0d464f
		   unsigned int height = 0,
Packit 0d464f
		   const PreviewRgba pixels[] = 0);
Packit 0d464f
Packit 0d464f
    //-----------------------------------------------------
Packit 0d464f
    // Copy constructor, destructor and assignment operator
Packit 0d464f
    //-----------------------------------------------------
Packit 0d464f
Packit 0d464f
     PreviewImage (const PreviewImage &other);
Packit 0d464f
    ~PreviewImage ();
Packit 0d464f
Packit 0d464f
    PreviewImage &	operator = (const PreviewImage &other);
Packit 0d464f
Packit 0d464f
Packit 0d464f
    //-----------------------------------------------
Packit 0d464f
    // Access to width, height and to the pixel array
Packit 0d464f
    //-----------------------------------------------
Packit 0d464f
Packit 0d464f
    unsigned int	width () const	{return _width;}
Packit 0d464f
    unsigned int	height () const	{return _height;}
Packit 0d464f
Packit 0d464f
    PreviewRgba *	pixels ()	{return _pixels;}
Packit 0d464f
    const PreviewRgba *	pixels () const	{return _pixels;}
Packit 0d464f
Packit 0d464f
Packit 0d464f
    //----------------------------
Packit 0d464f
    // Access to individual pixels
Packit 0d464f
    //----------------------------
Packit 0d464f
Packit 0d464f
    PreviewRgba &	pixel (unsigned int x, unsigned int y)
Packit 0d464f
    					{return _pixels[y * _width + x];}
Packit 0d464f
Packit 0d464f
    const PreviewRgba &	pixel (unsigned int x, unsigned int y) const
Packit 0d464f
    					{return _pixels[y * _width + x];}
Packit 0d464f
Packit 0d464f
  private:
Packit 0d464f
Packit 0d464f
    unsigned int	_width;
Packit 0d464f
    unsigned int	_height;
Packit 0d464f
    PreviewRgba *	_pixels;
Packit 0d464f
};
Packit 0d464f
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Packit 0d464f
Packit 0d464f
#endif