146 lines
2.8 KiB
C++
146 lines
2.8 KiB
C++
#ifndef _BROWSE_DIB24_HPP_
|
|
#define _BROWSE_DIB24_HPP_
|
|
#ifndef _COMMON_WINDOWS_HPP_
|
|
#include <common/windows.hpp>
|
|
#endif
|
|
#ifndef _COMMON_POINT_HPP_
|
|
#include <common/point.hpp>
|
|
#endif
|
|
#ifndef _COMMON_PUREDEVICE_HPP_
|
|
#include <common/purehdc.hpp>
|
|
#endif
|
|
#ifndef _BROWSE_JPGIMAGE_HPP_
|
|
#include <browse/jpgimg.hpp>
|
|
#endif
|
|
#ifndef _BROWSE_RGB888_HPP_
|
|
#include <browse/rgb888.hpp>
|
|
#endif
|
|
|
|
class DIB24
|
|
{
|
|
public:
|
|
DIB24(void);
|
|
virtual ~DIB24();
|
|
bool create(int width,int height,PureDevice &pureDevice);
|
|
bool draw(PureDevice &pureDevice,const Rect &dstRect,const Point &srcPoint);
|
|
bool setBits(BYTE value);
|
|
bool getAt(DWORD row,DWORD col,RGB888 &someRGB888)const;
|
|
bool setAt(DWORD row,DWORD col,const RGB888 &someRGB888);
|
|
bool setAt(DWORD row,DWORD col,JPGImage &jpgImage);
|
|
RGB888 *rgbArray(void);
|
|
DWORD extent(void)const;
|
|
DWORD width(void)const;
|
|
DWORD height(void)const;
|
|
HBITMAP getBitmap(void);
|
|
bool isOkay(void)const;
|
|
private:
|
|
DIB24(const DIB24 &someDIB24);
|
|
DIB24 &operator=(const DIB24 &someDIB24);
|
|
void verifyDimensions(BitmapInfo &someBitmapInfo);
|
|
void destroy(void);
|
|
|
|
HBITMAP mhBitmap;
|
|
RGB888 *mpRGBArray;
|
|
BitmapInfo mBitmapInfo;
|
|
DWORD mExtent;
|
|
};
|
|
|
|
inline
|
|
DIB24::DIB24(void)
|
|
: mhBitmap(0), mpRGBArray(0), mExtent(0)
|
|
{
|
|
}
|
|
|
|
inline
|
|
DIB24::DIB24(const DIB24 &someDIB24)
|
|
{ // private implementation
|
|
*this=someDIB24;
|
|
}
|
|
|
|
inline
|
|
DIB24::~DIB24()
|
|
{
|
|
destroy();
|
|
}
|
|
|
|
inline
|
|
RGB888 *DIB24::rgbArray(void)
|
|
{
|
|
return mpRGBArray;
|
|
}
|
|
|
|
inline
|
|
DWORD DIB24::extent(void)const
|
|
{
|
|
return mExtent;
|
|
}
|
|
|
|
inline
|
|
DIB24 &DIB24::operator=(const DIB24 &/*someDIB24*/)
|
|
{ // private implementation
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
DWORD DIB24::width(void)const
|
|
{
|
|
if(!isOkay())return 0;
|
|
return mBitmapInfo.width();
|
|
}
|
|
|
|
inline
|
|
DWORD DIB24::height(void)const
|
|
{
|
|
if(!isOkay())return 0;
|
|
return mBitmapInfo.height()<0?-mBitmapInfo.height():mBitmapInfo.height();
|
|
}
|
|
|
|
inline
|
|
void DIB24::destroy(void)
|
|
{
|
|
if(!mhBitmap)return;
|
|
::DeleteObject(mhBitmap);
|
|
mhBitmap=0;
|
|
mpRGBArray=0;
|
|
mExtent=0;
|
|
}
|
|
|
|
inline
|
|
HBITMAP DIB24::getBitmap(void)
|
|
{
|
|
return mhBitmap;
|
|
}
|
|
|
|
inline
|
|
bool DIB24::setBits(BYTE value)
|
|
{
|
|
if(!isOkay())return FALSE;
|
|
::memset(mpRGBArray,value,extent()*sizeof(RGB888));
|
|
return true;
|
|
}
|
|
|
|
inline
|
|
bool DIB24::getAt(DWORD row,DWORD col,RGB888 &someRGB888)const
|
|
{
|
|
if(!isOkay())return false;
|
|
if(mBitmapInfo.height()<0)someRGB888=mpRGBArray[row*width()+col];
|
|
else someRGB888=mpRGBArray[(mBitmapInfo.width()*(-mBitmapInfo.height()))-(((row*mBitmapInfo.width())+mBitmapInfo.width()))+col];
|
|
return true;
|
|
}
|
|
|
|
inline
|
|
bool DIB24::setAt(DWORD row,DWORD col,const RGB888 &someRGB888)
|
|
{
|
|
if(!isOkay())return false;
|
|
if(mBitmapInfo.height()<0)mpRGBArray[row*width()+col]=someRGB888;
|
|
else mpRGBArray[(mBitmapInfo.width()*(-mBitmapInfo.height()))-(((row*mBitmapInfo.width())+mBitmapInfo.width()))+col]=someRGB888;
|
|
return true;
|
|
}
|
|
|
|
inline
|
|
bool DIB24::isOkay(void)const
|
|
{
|
|
return mhBitmap?true:false;
|
|
}
|
|
#endif
|