129 lines
2.7 KiB
C++
129 lines
2.7 KiB
C++
#ifndef _JPGIMG_JPGIMAGE_HPP_
|
|
#define _JPGIMG_JPGIMAGE_HPP_
|
|
#ifndef _COMMON_WINDOWS_HPP_
|
|
#include <common/windows.hpp>
|
|
#endif
|
|
#ifndef _COMMON_DIBITMAP_HPP_
|
|
#include <common/dib.hpp>
|
|
#endif
|
|
#ifndef _COMMON_BITMAPINFO_HPP_
|
|
#include <common/bminfo.hpp>
|
|
#endif
|
|
#ifndef _JPGIMG_RGB888_HPP_
|
|
#include <jpgimg/rgb888.hpp>
|
|
#endif
|
|
#ifndef _JPGIMG_RAWIMAGE_HPP_
|
|
#include <jpgimg/rawimg.hpp>
|
|
#endif
|
|
|
|
class String;
|
|
class PureDevice;
|
|
class RGB888;
|
|
|
|
class JPGImage : public RawImage
|
|
{
|
|
public:
|
|
class JPGImageInvalidImage{};
|
|
JPGImage(void);
|
|
virtual ~JPGImage();
|
|
bool decode(const String &strPathFileName,PureDevice &pureDevice);
|
|
bool decode(const String &strPathFileName);
|
|
bool saveBitmap(const String &strPathFileName);
|
|
bool draw(PureDevice &pureDevice);
|
|
bool draw(PureDevice &pureDevice,int xSrc,int ySrc);
|
|
bool draw(PureDevice &pureDevice,const Rect &dstRect,const Point &srcPoint);
|
|
bool stretch(PureDevice &pureDevice,const Point &xyPoint,int strwidth,int strheight);
|
|
bool rotateLeft(PureDevice &pureDevice);
|
|
bool rotateRight(PureDevice &pureDevice);
|
|
bool resample(PureDevice &pureDevice,int width);
|
|
bool resample(PureDevice &pureDevice,int newWidth,int newHeight);
|
|
bool resample(int newWidth,int newHeight);
|
|
DWORD memoryUsage(void)const;
|
|
bool isOkay(void)const;
|
|
int width(void)const;
|
|
int height(void)const;
|
|
bool getRawData(GlobalData<BYTE> &rawData);
|
|
bool setRawData(GlobalData<BYTE> &rawData,PureDevice &pureDevice);
|
|
bool setRawData(GlobalData<BYTE> &rawData);
|
|
bool getAt(DWORD row,DWORD col,RGB888 &rgb888)const;
|
|
private:
|
|
JPGImage(const JPGImage &someJPGImage);
|
|
JPGImage &operator=(const JPGImage &someJPGImage);
|
|
void copyRow(RGB888 *pDstArray,RGB888 *pSrcArray,int length);
|
|
void destroy(void);
|
|
|
|
HBITMAP mhBitmap;
|
|
};
|
|
|
|
inline
|
|
JPGImage::JPGImage(void)
|
|
: mhBitmap(0)
|
|
{
|
|
}
|
|
|
|
inline
|
|
JPGImage::JPGImage(const JPGImage &someJPGImage)
|
|
: mhBitmap(0)
|
|
{ // private implementation
|
|
*this=someJPGImage;
|
|
}
|
|
|
|
inline
|
|
JPGImage &JPGImage::operator=(const JPGImage &someJPGImage)
|
|
{ // private implementation
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
JPGImage::~JPGImage()
|
|
{
|
|
destroy();
|
|
}
|
|
|
|
inline
|
|
int JPGImage::width(void)const
|
|
{
|
|
return getBitmapInfo().width();
|
|
}
|
|
|
|
inline
|
|
int JPGImage::height(void)const
|
|
{
|
|
if(getBitmapInfo().height()<0)return -getBitmapInfo().height();
|
|
return getBitmapInfo().height();
|
|
}
|
|
|
|
inline
|
|
bool JPGImage::getAt(DWORD row,DWORD col,RGB888 &rgb888)const
|
|
{
|
|
return RawImage::getAt(row,col,rgb888);
|
|
}
|
|
|
|
inline
|
|
bool JPGImage::isOkay(void)const
|
|
{
|
|
return mhBitmap?TRUE:FALSE;
|
|
}
|
|
|
|
inline
|
|
void JPGImage::destroy(void)
|
|
{
|
|
if(!mhBitmap)return;
|
|
::DeleteObject(mhBitmap);
|
|
mhBitmap=0;
|
|
}
|
|
|
|
inline
|
|
DWORD JPGImage::memoryUsage(void)const
|
|
{
|
|
return RawImage::memoryUsage();
|
|
}
|
|
|
|
inline
|
|
bool JPGImage::setRawData(GlobalData<BYTE> &rawData)
|
|
{
|
|
destroy();
|
|
return RawImage::setRawData(rawData);
|
|
}
|
|
#endif
|