1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __I_IMAGE_H_INCLUDED__
6
#define __I_IMAGE_H_INCLUDED__
8
#include "IReferenceCounted.h"
9
#include "position2d.h"
18
//! Interface for software image data.
19
/** Image loaders create these images from files. IVideoDrivers convert
20
these images into their (hardware) textures.
22
class IImage : public virtual IReferenceCounted
26
//! Lock function. Use this to get a pointer to the image data.
27
/** After you don't need the pointer anymore, you must call unlock().
28
\return Pointer to the image data. What type of data is pointed to
29
depends on the color format of the image. For example if the color
30
format is ECF_A8R8G8B8, it is of u32. Be sure to call unlock() after
31
you don't need the pointer any more. */
32
virtual void* lock() = 0;
35
/** Should be called after the pointer received by lock() is not
37
virtual void unlock() = 0;
39
//! Returns width and height of image data.
40
virtual const core::dimension2d<u32>& getDimension() const = 0;
42
//! Returns bits per pixel.
43
virtual u32 getBitsPerPixel() const = 0;
45
//! Returns bytes per pixel
46
virtual u32 getBytesPerPixel() const = 0;
48
//! Returns image data size in bytes
49
virtual u32 getImageDataSizeInBytes() const = 0;
51
//! Returns image data size in pixels
52
virtual u32 getImageDataSizeInPixels() const = 0;
55
virtual SColor getPixel(u32 x, u32 y) const = 0;
58
virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ) = 0;
60
//! Returns the color format
61
virtual ECOLOR_FORMAT getColorFormat() const = 0;
63
//! Returns mask for red value of a pixel
64
virtual u32 getRedMask() const = 0;
66
//! Returns mask for green value of a pixel
67
virtual u32 getGreenMask() const = 0;
69
//! Returns mask for blue value of a pixel
70
virtual u32 getBlueMask() const = 0;
72
//! Returns mask for alpha value of a pixel
73
virtual u32 getAlphaMask() const = 0;
75
//! Returns pitch of image
76
virtual u32 getPitch() const =0;
78
//! Copies the image into the target, scaling the image to fit
79
virtual void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0) =0;
81
//! Copies the image into the target, scaling the image to fit
82
virtual void copyToScaling(IImage* target) =0;
84
//! copies this surface into another
85
virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0)) =0;
87
//! copies this surface into another
88
virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0) =0;
90
//! copies this surface into another, using the alpha mask and cliprect and a color to add with
91
virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos,
92
const core::rect<s32>& sourceRect, const SColor &color,
93
const core::rect<s32>* clipRect = 0) =0;
95
//! copies this surface into another, scaling it to fit, appyling a box filter
96
virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false) = 0;
98
//! fills the surface with given color
99
virtual void fill(const SColor &color) =0;
101
//! get the amount of Bits per Pixel of the given color format
102
static u32 getBitsPerPixelFromFormat(const ECOLOR_FORMAT format)
118
case ECF_A16B16G16R16F:
124
case ECF_A32B32G32R32F:
131
//! test if the color format is only viable for RenderTarget textures
132
/** Since we don't have support for e.g. floating point IImage formats
133
one should test if the color format can be used for arbitrary usage, or
134
if it is restricted to RTTs. */
135
static bool isRenderTargetOnlyFormat(const ECOLOR_FORMAT format)
151
} // end namespace video
152
} // end namespace irr