void dbMakeMemblockFromBitmap ( int MemblockNumber, int BitmapNumber )
and (more directly)
void dbMakeBitmapFromMemblock ( int BitmapNumber, int MemblockNumber )
or
void dbCopyBitmap ( int iFrom, int iTo )
and
void dbCopyBitmap ( int iFrom, int iLeft, int iTop, int iRight, int iBottom, int iTo, int iLeft, int iTop, int iRight, int iBottom )
But you'll need to do a bit of setup. The memblock and the bitmaps must both previously exist and most likely need to be set up with the right sizes. Otherwise, following is a Bitmap class I wrote to take care of some of this but really just encapsulates these the bitmap functions into a class.
bitmap.h
// Header file for bitmaps
#include "DarkGDK.h"
#include "Utility.h"
#ifndef _BITMAP_H_
#define _BITMAP_H_
class Bitmap
{
private:
int width;
int height;
int depth;
bool flipped;
bool mirrored;
static int nextBitmapNumber;
int pixelPointer;
int pitch;
protected:
int bitmapNumber;
int backgroundColor;
int foregroundColor;
public:
Bitmap ()
{
width = height = 1;
flipped = mirrored = false;
bitmapNumber = nextBitmapNumber++;
}
Bitmap (int w, int h)
{
bitmapNumber = nextBitmapNumber++;
flipped = mirrored = false;
width = w;
height = h;
}
~Bitmap ()
{
if (Exist()) dbDeleteBitmap (bitmapNumber); // GDK kills sprite
// recover the bitmap number
if (bitmapNumber == (nextBitmapNumber - 1)) nextBitmapNumber--;
}
void Delete ()
{
if (Exist()) dbDeleteBitmap (bitmapNumber);
}
static int CurrentBitmap(void); // this returns the number of the current system
// bitmap rather than the bitmap number for this bitmap
void CopyTo (Bitmap const dest);
void CopyTo(int dest);
bool Exist (void);
void AssignGraphic(char *file);
void ReSize (int w, int h);
void SetCurrent(void);
void Create(void);
void SetColors (int fg, int bg);
void Cls (int clr);
void Dot (int x, int y);
void Dot (int x, int y, int clr);
int Point (int x, int y);
void Lock(void);
void Unlock(void);
int PixelPointer(void);
int PixelPitch(void);
operator int() { return bitmapNumber; }
void DrawLine (int x1, int y1, int x2, int y2);
void Blur (int factor);
void Fade (int factor);
void Flip();
void Mirror();
void Box (int xul, int yul, int xlr, int ylr);
void Box(point ul, point lr);
void Circle(int xc, int yc, int r);
void Circle(point center, int radius);
void Ellipse (int xc, int yc, int xradius, int yradius);
void Ellipse (point center, int xradius, int yradius);
bool Flipped(void);
bool Mirrored(void);
void Unflip(void);
void Unmirror(void);
int GetForeground(){return foregroundColor;}
int GetBackground(){return backgroundColor;}
};
#endif
bitmap.cpp
#include "Bitmap.h"
int Bitmap::nextBitmapNumber = 1;
int Bitmap::CurrentBitmap(void)
{
return dbCurrentBitmap();
}
void Bitmap::SetCurrent()
{
Create();
dbSetCurrentBitmap(bitmapNumber);
}
void Bitmap::CopyTo(Bitmap dest)
{
if (Exist())
dbCopyBitmap (this->bitmapNumber, dest.bitmapNumber);
}
void Bitmap::CopyTo(int dest)
{
if (Exist())
dbCopyBitmap (this->bitmapNumber, dest);
dbSetCurrentBitmap(dest); // a precaution, especially if it's the screen
}
void Bitmap::AssignGraphic(char *file)
{
Create();
dbLoadBitmap (file, this->bitmapNumber);
SetCurrent();
width = dbBitmapWidth (bitmapNumber);
height = dbBitmapHeight (bitmapNumber);
}
void Bitmap::SetColors(int fg, int bg)
{
foregroundColor = fg;
backgroundColor = bg;
SetCurrent();
dbInk (fg, bg);
}
void Bitmap::Cls(int clr)
{
Create();
dbCLS (clr);
}
void Bitmap::Dot(int x, int y)
{
Create();
dbDot (x, y);
}
void Bitmap::Dot(int x, int y, int clr)
{
Create();
dbDot(x, y, clr);
}
int Bitmap::Point(int x, int y)
{
SetCurrent();
return dbPoint(x, y);
}
void Bitmap::Lock(void)
{
SetCurrent();
dbLockPixels();
}
void Bitmap::Unlock(void)
{
SetCurrent();
dbUnlockPixels();
}
int Bitmap::PixelPointer(void)
{
SetCurrent();
return (pixelPointer = dbGetPixelsPointer());
}
int Bitmap::PixelPitch(void)
{
SetCurrent();
return (pitch = dbGetPixelsPitch());
}
void Bitmap::DrawLine(int x1, int y1, int x2, int y2)
{
Create();
dbLine (x1, y1, x2, y2);
}
bool Bitmap::Exist()
{
return (dbBitmapExist (bitmapNumber) == 1);
}
void Bitmap::Create()
{
if (!Exist()){
if (width == 0) width = 1;
if (height == 0) height = 1;
dbCreateBitmap(bitmapNumber, width, height);
SetCurrent();
}
}
void Bitmap::ReSize(int w, int h)
{
if (Exist()) dbDeleteBitmap(bitmapNumber);
dbCreateBitmap(bitmapNumber, width = w, height = h);
depth = dbBitmapDepth(bitmapNumber);
SetCurrent();
}
void Bitmap::Blur(int factor)
{
Create();
if (factor > 6) factor = 6;
dbBlurBitmap(bitmapNumber, factor);
}
void Bitmap::Fade(int factor)
{
Create();
if (factor > 100) factor = 100;
dbFadeBitmap (bitmapNumber, factor);
}
void Bitmap::Flip()
{
Create();
dbFlipBitmap(bitmapNumber);
flipped = (dbBitmapFlipped(bitmapNumber) == 1);
}
void Bitmap::Mirror()
{
Create();
dbMirrorBitmap(bitmapNumber);
mirrored = (dbBitmapMirrored(bitmapNumber) == 1);
}
void Bitmap::Box (int xul, int yul, int xlr, int ylr)
{
Create();
dbBox (xul, yul, xlr, ylr);
}
void Bitmap::Box(point ul, point lr)
{
Create();
dbBox (ul.x, ul.y, lr.x, lr.y);
}
void Bitmap::Circle(int xc, int yc, int r)
{
Create();
dbCircle (xc, yc, r);
}
void Bitmap::Circle(point center, int radius)
{
Create();
dbCircle (center.x, center.y, radius);
}
void Bitmap::Ellipse (int xc, int yc, int xradius, int yradius)
{
Create();
dbEllipse (xc, yc, xradius, yradius);
}
void Bitmap::Ellipse (point center, int xradius, int yradius)
{
Create();
dbEllipse (center.x, center.y, xradius, yradius);
}
bool Bitmap::Flipped(void)
{
return flipped = (dbBitmapFlipped(bitmapNumber) == 1);
}
bool Bitmap::Mirrored(void)
{
return mirrored = (dbBitmapMirrored(bitmapNumber) == 1);
}
void Bitmap::Unflip(void)
{
if (Flipped())dbFlipBitmap(bitmapNumber);
}
void Bitmap::Unmirror(void)
{
if (Mirrored()) dbMirrorBitmap(bitmapNumber);
}
Lilith, Night Butterfly
I'm not a programmer but I play one in the office