2008-05-22 04:51:37 -07:00
|
|
|
// Copyright (C) 2002-2008 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __I_IMAGE_H_INCLUDED__
|
|
|
|
#define __I_IMAGE_H_INCLUDED__
|
|
|
|
|
2007-09-06 23:11:47 -07:00
|
|
|
#include "IReferenceCounted.h"
|
2007-05-20 11:03:49 -07:00
|
|
|
#include "position2d.h"
|
|
|
|
#include "SColor.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace video
|
|
|
|
{
|
|
|
|
|
|
|
|
//! An enum for the color format of textures used by the Irrlicht Engine.
|
|
|
|
/** A color format specifies how color information is stored. */
|
|
|
|
enum ECOLOR_FORMAT
|
|
|
|
{
|
2008-05-22 04:51:37 -07:00
|
|
|
//! 16 bit color format used by the software driver.
|
|
|
|
/** It is thus preferred by all other irrlicht engine video drivers.
|
|
|
|
There are 5 bits for every color component, and a single bit is left
|
|
|
|
for alpha information. */
|
2007-05-20 11:03:49 -07:00
|
|
|
ECF_A1R5G5B5 = 0,
|
|
|
|
|
|
|
|
//! Standard 16 bit color format.
|
|
|
|
ECF_R5G6B5,
|
|
|
|
|
|
|
|
//! 24 bit color, no alpha channel, but 8 bit for red, green and blue.
|
|
|
|
ECF_R8G8B8,
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Default 32 bit color format. 8 bits are used for every component: red, green, blue and alpha.
|
2007-05-20 11:03:49 -07:00
|
|
|
ECF_A8R8G8B8
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Interface for software image data.
|
2007-05-20 11:03:49 -07:00
|
|
|
/** Image loaders create these images from files. IVideoDrivers convert
|
|
|
|
these images into their (hardware) textures.
|
|
|
|
*/
|
2007-09-06 23:11:47 -07:00
|
|
|
class IImage : public virtual IReferenceCounted
|
2007-05-20 11:03:49 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Destructor
|
2007-09-16 16:41:55 -07:00
|
|
|
virtual ~IImage() {}
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Lock function. Use this to get a pointer to the image data.
|
|
|
|
/** After you don't need the pointer anymore, you must call unlock().
|
|
|
|
\return Pointer to the image data. What type of data is pointed to
|
|
|
|
depends on the color format of the image. For example if the color
|
|
|
|
format is ECF_A8R8G8B8, it is of u32. Be sure to call unlock() after
|
|
|
|
you don't need the pointer any more. */
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual void* lock() = 0;
|
|
|
|
|
|
|
|
//! Unlock function.
|
2008-05-22 04:51:37 -07:00
|
|
|
/** Should be called after the pointer received by lock() is not
|
|
|
|
needed anymore. */
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual void unlock() = 0;
|
|
|
|
|
|
|
|
//! Returns width and height of image data.
|
|
|
|
virtual const core::dimension2d<s32>& getDimension() const = 0;
|
|
|
|
|
|
|
|
//! Returns bits per pixel.
|
|
|
|
virtual u32 getBitsPerPixel() const = 0;
|
|
|
|
|
|
|
|
//! Returns bytes per pixel
|
|
|
|
virtual u32 getBytesPerPixel() const = 0;
|
|
|
|
|
|
|
|
//! Returns image data size in bytes
|
|
|
|
virtual u32 getImageDataSizeInBytes() const = 0;
|
|
|
|
|
|
|
|
//! Returns image data size in pixels
|
|
|
|
virtual u32 getImageDataSizeInPixels() const = 0;
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Returns a pixel
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual SColor getPixel(u32 x, u32 y) const = 0;
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Sets a pixel
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual void setPixel(u32 x, u32 y, const SColor &color ) = 0;
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Returns the color format
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual ECOLOR_FORMAT getColorFormat() const = 0;
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Returns mask for red value of a pixel
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual u32 getRedMask() const = 0;
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Returns mask for green value of a pixel
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual u32 getGreenMask() const = 0;
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Returns mask for blue value of a pixel
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual u32 getBlueMask() const = 0;
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Returns mask for alpha value of a pixel
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual u32 getAlphaMask() const = 0;
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Returns pitch of image
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual u32 getPitch() const = 0;
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Copies the image into the target, scaling the image to fit
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual void copyToScaling(void* target, s32 width, s32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0) = 0;
|
|
|
|
|
2008-05-22 04:51:37 -07:00
|
|
|
//! Copies the image into the target, scaling the image to fit
|
2007-05-20 11:03:49 -07:00
|
|
|
virtual void copyToScaling(IImage* target) = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace video
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|