|
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1998 by J�rg K�nig
// All rights reserved
//
// This file is part of the completely free tetris clone "CGTetris".
//
// This is free software.
// You may redistribute it by any means providing it is not sold for profit
// without the authors written consent.
//
// No warrantee of any kind, expressed or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// J.Koenig@adg.de (company site)
// Joerg.Koenig@rhein-neckar.de (private site)
/////////////////////////////////////////////////////////////////////////////
#ifndef __DIB256_H__
#define __DIB256_H__
class CDIBitmap
{
friend class CBmpPalette;
BITMAPINFO * m_pInfo;
BYTE * m_pPixels;
CBmpPalette * m_pPal;
BOOL m_bIsPadded;
public: //constructors
CDIBitmap();
virtual ~CDIBitmap();
private:
CDIBitmap( const CDIBitmap& dbmp );
public: // attributes
BITMAPINFO * GetHeaderPtr() const;
BYTE * GetPixelPtr() const;
RGBQUAD * GetColorTablePtr() const;
int GetWidth() const;
int GetHeight() const;
CBmpPalette * GetPalette() { return m_pPal; }
public: // operations
BOOL CreatePalette(); // auto. made by "Load()" and "CreateFromBitmap()"
void ClearPalette(); // destroy the palette associated with this image
BOOL CreateFromBitmap( CDC *, CBitmap * );
BOOL LoadResource(LPCTSTR ID);
BOOL LoadResource(UINT ID) { return LoadResource(MAKEINTRESOURCE(ID)); }
BOOL LoadBitmap(UINT ID) { return LoadResource(ID); }
BOOL LoadBitmap(LPCTSTR ID) { return LoadResource(ID); }
void DestroyBitmap();
BOOL DeleteObject() { DestroyBitmap(); return TRUE; }
BOOL IsEmpty(void) const { return (m_pInfo == NULL); }
public: // overridables
// draw the bitmap at the specified location
virtual void DrawDIB( CDC * pDC, int x=0, int y=0 );
// draw the bitmap and stretch/compress it to the desired size
virtual void DrawDIB( CDC * pDC, int x, int y, int width, int height );
// draw parts of the dib into a given area of the DC
virtual int DrawDIB( CDC * pDC, CRect & rectDC, CRect & rectDIB );
// load a bitmap from disk
virtual BOOL Load( CFile * pFile );
virtual BOOL Load( const CString & );
// save the bitmap to disk
virtual BOOL Save( CFile * pFile );
virtual BOOL Save( const CString & );
protected:
int GetPalEntries() const;
int GetPalEntries( BITMAPINFOHEADER& infoHeader ) const;
DWORD GetBitsPerPixel() const;
DWORD LastByte( DWORD BitsPerPixel, DWORD PixelCount ) const;
DWORD GetBytesPerLine( DWORD BitsPerPixel, DWORD Width ) const;
BOOL PadBits();
BOOL UnPadBits();
WORD GetColorCount() const;
};
#include "dibpal.h"
#endif // __DIB256_H__
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I haven't always written software for a living. When I graduated from Surrey University in 1989, it was with an Electronic Engineering degree, but unfortunately that never really gave me the opportunity to do anything particularly interesting (with the possible exception of designing
Darth Vader's Codpiece * for the UK Army in 1990).
* Also known as the Standard Army Bootswitch. But that's another story...
Since the opportunity arose to lead a software team developing C++ software for
Avionic Test Systems in 1996, I've not looked back. More recently I've been involved in the development of subsea acoustic navigation systems, digital TV broadcast systems, port security/tracking systems, and most recently software development tools with my own company,
Riverblade Ltd.
One of my personal specialities is IDE plug-in development.
ResOrg was my first attempt at a plug-in, but my day to day work is with
Visual Lint, an interactive code analysis tool environment with works within the Visual Studio and Eclipse IDEs or on build servers.
I love lots of things, but particularly music, photography and anything connected with history or engineering. I
despise ignorant, intolerant and obstructive people - and it shows...I can be a bolshy cow if you wind me up the wrong way...
I'm currently based 15 minutes walk from the beach in Bournemouth on the south coast of England. Since I moved here I've grown to love the place - even if it is full of grockles in Summer!