86 lines
1.8 KiB
C++
86 lines
1.8 KiB
C++
#ifndef _BITMAP_HPP_
|
|
#define _BITMAP_HPP_
|
|
#include <stdio.h>
|
|
#include <mdiwin/windows.hpp>
|
|
#include <mdiwin/types.hpp>
|
|
#include <mdiwin/string.hpp>
|
|
|
|
class Bitmap
|
|
{
|
|
public:
|
|
enum {MaxColors=256};
|
|
Bitmap(void);
|
|
Bitmap(String pathFileName);
|
|
Bitmap(String pathFileName,HGLOBAL hGlobalImage,HGLOBAL hGlobalBitmapInfo);
|
|
~Bitmap();
|
|
WORD operator=(String pathFileName);
|
|
void operator=(const Bitmap &someBitmap);
|
|
WORD operator==(const Bitmap &someBitmap)const;
|
|
WORD isOkay(void)const;
|
|
WORD displayBitmap(HWND hDisplayWindow,HDC hDC=(HDC)0,int isActive=FALSE,int conforming=FALSE)const;
|
|
WORD saveBitmap(void)const;
|
|
HGLOBAL lockedImageData(void)const;
|
|
HGLOBAL lockedBitmapInfo(void)const;
|
|
HPALETTE paletteHandle(void)const;
|
|
WORD setPalette(HPALETTE hPalette);
|
|
WORD isValidBitmap(String pathFileName)const;
|
|
private:
|
|
enum Mode{Read,Write,Idle};
|
|
enum {Signature=0x4D42};
|
|
void cleanup(void);
|
|
void createPalette(void);
|
|
void decodeImage(void);
|
|
void copyBits(UHUGE *destination,UHUGE *source,unsigned long length)const;
|
|
WORD processBitmap(String pathFileName);
|
|
|
|
String mFileName;
|
|
WORD mMaxColors;
|
|
Mode mCurrentMode;
|
|
BITMAPFILEHEADER mBitmapFileHeader;
|
|
HPALETTE mhPalette;
|
|
HGLOBAL mhGlobalImage;
|
|
HGLOBAL mhGlobalBitmapInfo;
|
|
LONG mSizeImage;
|
|
const LONG mBlockSize;
|
|
UHUGE *mpImage;
|
|
BITMAPINFO *mpBitmapInfo;
|
|
HFILE mhFile;
|
|
};
|
|
|
|
inline
|
|
WORD Bitmap::isOkay(void)const
|
|
{
|
|
return (mhGlobalImage&&mhGlobalBitmapInfo);
|
|
}
|
|
|
|
inline
|
|
HGLOBAL Bitmap::lockedImageData(void)const
|
|
{
|
|
return mhGlobalImage;
|
|
}
|
|
|
|
inline
|
|
HGLOBAL Bitmap::lockedBitmapInfo(void)const
|
|
{
|
|
return mhGlobalBitmapInfo;
|
|
}
|
|
|
|
inline
|
|
HPALETTE Bitmap::paletteHandle(void)const
|
|
{
|
|
return mhPalette;
|
|
}
|
|
|
|
inline
|
|
WORD Bitmap::operator==(const Bitmap &someBitmap)const
|
|
{
|
|
return mFileName==someBitmap.mFileName;
|
|
}
|
|
|
|
inline
|
|
void Bitmap::operator=(const Bitmap &someBitmap)
|
|
{
|
|
(*this)=someBitmap.mFileName;
|
|
}
|
|
#endif
|