1 // This file is part of the "Irrlicht Engine".
\r
2 // written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de
\r
3 // modified by Thomas Alten
\r
5 #include "CGUIImageList.h"
\r
14 CGUIImageList::CGUIImageList( video::IVideoDriver* driver )
\r
20 UseAlphaChannel( false )
\r
23 setDebugName( "CGUIImageList" );
\r
35 CGUIImageList::~CGUIImageList()
\r
49 //! Creates the image list from texture.
\r
50 bool CGUIImageList::createImageList(video::ITexture* texture,
\r
51 core::dimension2d<s32> imageSize,
\r
52 bool useAlphaChannel)
\r
62 ImageSize = imageSize;
\r
64 ImagesPerRow = Texture->getSize().Width / ImageSize.Width;
\r
65 ImageCount = ImagesPerRow * Texture->getSize().Height / ImageSize.Height;
\r
67 UseAlphaChannel = useAlphaChannel;
\r
72 //! Draws an image and clips it to the specified rectangle if wanted
\r
73 void CGUIImageList::draw( s32 index, const core::position2d<s32>& destPos,
\r
74 const core::rect<s32>* clip /*= 0*/ )
\r
76 core::rect<s32> sourceRect;
\r
78 if( !Driver || index < 0 || index >= ImageCount )
\r
83 sourceRect.UpperLeftCorner.X = ( index % ImagesPerRow ) * ImageSize.Width;
\r
84 sourceRect.UpperLeftCorner.Y = ( index / ImagesPerRow ) * ImageSize.Height;
\r
85 sourceRect.LowerRightCorner.X = sourceRect.UpperLeftCorner.X + ImageSize.Width;
\r
86 sourceRect.LowerRightCorner.Y = sourceRect.UpperLeftCorner.Y + ImageSize.Height;
\r
88 Driver->draw2DImage( Texture, destPos, sourceRect, clip,
\r
89 video::SColor( 255, 255, 255, 255 ), UseAlphaChannel );
\r
92 } // end namespace gui
\r
93 } // end namespace irr
\r