~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to include/IImage.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
4
 
 
5
#ifndef __I_IMAGE_H_INCLUDED__
 
6
#define __I_IMAGE_H_INCLUDED__
 
7
 
 
8
#include "IReferenceCounted.h"
 
9
#include "position2d.h"
 
10
#include "rect.h"
 
11
#include "SColor.h"
 
12
 
 
13
namespace irr
 
14
{
 
15
namespace video
 
16
{
 
17
 
 
18
//! Interface for software image data.
 
19
/** Image loaders create these images from files. IVideoDrivers convert
 
20
these images into their (hardware) textures.
 
21
*/
 
22
class IImage : public virtual IReferenceCounted
 
23
{
 
24
public:
 
25
 
 
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;
 
33
 
 
34
        //! Unlock function.
 
35
        /** Should be called after the pointer received by lock() is not
 
36
        needed anymore. */
 
37
        virtual void unlock() = 0;
 
38
 
 
39
        //! Returns width and height of image data.
 
40
        virtual const core::dimension2d<u32>& getDimension() const = 0;
 
41
 
 
42
        //! Returns bits per pixel.
 
43
        virtual u32 getBitsPerPixel() const = 0;
 
44
 
 
45
        //! Returns bytes per pixel
 
46
        virtual u32 getBytesPerPixel() const = 0;
 
47
 
 
48
        //! Returns image data size in bytes
 
49
        virtual u32 getImageDataSizeInBytes() const = 0;
 
50
 
 
51
        //! Returns image data size in pixels
 
52
        virtual u32 getImageDataSizeInPixels() const = 0;
 
53
 
 
54
        //! Returns a pixel
 
55
        virtual SColor getPixel(u32 x, u32 y) const = 0;
 
56
 
 
57
        //! Sets a pixel
 
58
        virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ) = 0;
 
59
 
 
60
        //! Returns the color format
 
61
        virtual ECOLOR_FORMAT getColorFormat() const = 0;
 
62
 
 
63
        //! Returns mask for red value of a pixel
 
64
        virtual u32 getRedMask() const = 0;
 
65
 
 
66
        //! Returns mask for green value of a pixel
 
67
        virtual u32 getGreenMask() const = 0;
 
68
 
 
69
        //! Returns mask for blue value of a pixel
 
70
        virtual u32 getBlueMask() const = 0;
 
71
 
 
72
        //! Returns mask for alpha value of a pixel
 
73
        virtual u32 getAlphaMask() const = 0;
 
74
 
 
75
        //! Returns pitch of image
 
76
        virtual u32 getPitch() const =0;
 
77
 
 
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;
 
80
 
 
81
        //! Copies the image into the target, scaling the image to fit
 
82
        virtual void copyToScaling(IImage* target) =0;
 
83
 
 
84
        //! copies this surface into another
 
85
        virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0)) =0;
 
86
 
 
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;
 
89
 
 
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;
 
94
 
 
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;
 
97
 
 
98
        //! fills the surface with given color
 
99
        virtual void fill(const SColor &color) =0;
 
100
 
 
101
        //! get the amount of Bits per Pixel of the given color format
 
102
        static u32 getBitsPerPixelFromFormat(const ECOLOR_FORMAT format)
 
103
        {
 
104
                switch(format)
 
105
                {
 
106
                case ECF_A1R5G5B5:
 
107
                        return 16;
 
108
                case ECF_R5G6B5:
 
109
                        return 16;
 
110
                case ECF_R8G8B8:
 
111
                        return 24;
 
112
                case ECF_A8R8G8B8:
 
113
                        return 32;
 
114
                case ECF_R16F:
 
115
                        return 16;
 
116
                case ECF_G16R16F:
 
117
                        return 32;
 
118
                case ECF_A16B16G16R16F:
 
119
                        return 64;
 
120
                case ECF_R32F:
 
121
                        return 32;
 
122
                case ECF_G32R32F:
 
123
                        return 64;
 
124
                case ECF_A32B32G32R32F:
 
125
                        return 128;
 
126
                default:
 
127
                        return 0;
 
128
                }
 
129
        }
 
130
 
 
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)
 
136
        {
 
137
                switch(format)
 
138
                {
 
139
                        case ECF_A1R5G5B5:
 
140
                        case ECF_R5G6B5:
 
141
                        case ECF_R8G8B8:
 
142
                        case ECF_A8R8G8B8:
 
143
                                return false;
 
144
                        default:
 
145
                                return true;
 
146
                }
 
147
        }
 
148
 
 
149
};
 
150
 
 
151
} // end namespace video
 
152
} // end namespace irr
 
153
 
 
154
#endif
 
155