home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
bitmap2.zip
/
BITMAP.HPP
< prev
next >
Wrap
Text File
|
1994-12-01
|
3KB
|
77 lines
/* Bitmap.hpp
Bitmap Class Header
Copyright 1994, Bill Leonard
The author will not be liable for any bug, error, omission,
defect, deficiency, or nonconformity in this software. The author
also disclaims all implied warranties, including without limitation
warranties of merchantability, performance, and fitness for a
particular purpose. This software is provided "as is" and the user
assumes the entire risk as to its quality and performance.
*/
#ifndef BITMAP_HPP
#define BITMAP_HPP
#include <os2def.h>
#include <pmbitmap.h>
#include <ihandle.hpp>
#include <irect.hpp>
#include <ipoint.hpp>
#include <fstream.h>
class Bitmap {
private:
PBITMAPINFO2 _pbmi2 ; // bitmap info2
PBYTE _pbmb ; // bitmap bits
ULONG _ulScanlineSize ; // size of scan line
IHandle _hdc ; // associated DC handle
IPresSpaceHandle _hps ; // associated PS handle
IHandle _hpal ; // associated palette handle
IBitmapHandle _hbm ; // associated Gpi bitmap handle
public:
// constructors & destructor
Bitmap(IString const& fname) ; // construct from (unopened) BMP file
Bitmap(IBitmapHandle const& hbmp) ; // construct from GPI bitmap
Bitmap(BITMAPINFOHEADER2 const* pbmp) ; // construct from BITMAPINFOHEADER2
~Bitmap() ; // destructor
// Bitmap Component accessors
PBITMAPINFOHEADER2 bmp() const ; // BITMAPINFOHEADER2 accessor
PBITMAPINFO2 bmi() const ; // BITMAPINFO2 accessor
PRGB2 rgb(USHORT index=0) const ; // RGB2 color table accessor
PRGB2 rgb(USHORT row, USHORT col) const ; // bitmap pel color accessor
PBYTE bmb(USHORT row=0, USHORT col=0) const ; // bitmap bits image accessor
USHORT index(USHORT row, USHORT col) const ; // bitmap pel color index accessor
ULONG scanLineSize() const ; // returns scan line size
void setIndex(USHORT indx, USHORT row, USHORT col) const ; // set pel
// Gpi Bitmap stuff
IBitmapHandle createGpiBitmap(Boolean createPal=0) ; // create gpi bitmap (plus DC & PS)
void blitTo(IPresSpaceHandle hps=0) const ; // blit from image data to hps (default = _hps)
void blitTo(IPresSpaceHandle hps, IPoint const& dest,
IRectangle const& sourceRect) const ;
void blitFrom(IPresSpaceHandle hps=0) const ; // blit from hps (default = _hps) to image data
void blitFrom(IPresSpaceHandle hps, IPoint const& source,
IRectangle const& destRect) const ;
void disassociate() ; // remove association with Gpi bitmap
void deleteGpiBitmap() ; // delete Gpi bitmap (DC & PS, etc)
IBitmapHandle hbm() const ; // returns associated Gpi Bitmap Handle
IHandle hdc() const ; // returns associated device context handle
IPresSpaceHandle hps() const ; // returns associated presentation space handle
IHandle hpal() const ; // returns palette handle
// BMP file i/o (file is opened & positioned)
void load(ifstream& BMPfile) ; // load a bitmap (OS/2 or Win format)
void save1x(ofstream& BMPfile) const ; // save a bitmap (OS/2 V1.x format)
void save2x(ofstream& BMPfile) const ; // save a bitmap (OS/2 V2.x format)
};
#endif