Nice - but the image thing... its not so bad.
MAKE MEMBLOCK from IMAGE
Now you have your image in a memblock.
First 4 bytes are a DWORD - Width of image:
Psuedo - MyImageWidth = Read Memblock DWORD Position 0
Next 4 are Height:
Psuedo - MyImageHeight = Read Memblock DWORD Position 4
Next 4 are Bit depth - usually 32, and frankly - that's all I've seen or used so far - so this post only referes to 32bit depth format.
Psuedo - MyImageBitDepth = Read Memblock DWORD Position 8
From Position 12 on up to
memblock size are DWORDS also. Each one represents a Pixel. So each pixel is represented in four bytes. One byte is the RED, the another BLUE, Another Green, and Another the Alpha (Zero=transparent, >ZERO how much it should count when being drawn)
The exact order in mem I forget - meaning ... in a given pixel, I forget what comes first of the RGBA... what I USUALLY do - is something along the lines of:
(Snippets from my oop lib's JGC_PIXELGRID class.)
// To get the Memposition in a memblock that was made from an image:
//----------------------------------------------------------------------------
inline DWORD JGC_PIXELGRID::MemPos(int p_X, int p_Y){
//----------------------------------------------------------------------------
// 12 is the header size - BPP or Bytes Per Pixel Defaults to 4.
DWORD dwOffset=( (p_X + (p_Y*pvt_Width)) * pvt_BytesPerPixel)+12;
return dwOffset;
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
inline DWORD JGC_PIXELGRID::MemPos(int p_X, int p_Y, int p_Width){
//----------------------------------------------------------------------------
// 12 is the header size - BPP or Bytes Per Pixel Defaults to 4.
DWORD dwOffset=( (p_X + (p_Y*p_Width)) * pvt_BytesPerPixel)+12;
return dwOffset;
};
//----------------------------------------------------------------------------
Here - to access indivudla colors etc using above code for plotting the mem location:
//----------------------------------------------------------------------------
void JGC_PIXELGRID::Red_Set(int p_X, int p_Y, int p_Value){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
MB->Byte_Set(mp+2,p_Value);
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_PIXELGRID::Green_Set(int p_X, int p_Y, int p_Value){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
MB->Byte_Set(mp+1,p_Value);
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_PIXELGRID::Blue_Set(int p_X, int p_Y, int p_Value){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
MB->Byte_Set(mp,p_Value);
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_PIXELGRID::Alpha_Set(int p_X, int p_Y, int p_Value){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
MB->Byte_Set(mp+3,p_Value);
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_PIXELGRID::RGB_Set(int p_X, int p_Y, DWORD p_Value){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=this->MemPos(p_X,p_Y);
MB->Byte_Set(mp+0,(p_Value & 0x000f));
MB->Byte_Set(mp+1,(p_Value & 0x00f0));
MB->Byte_Set(mp+2,(p_Value & 0x0f00));
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_PIXELGRID::RGB_Set(int p_X, int p_Y, int p_R, int p_G, int p_B){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
MB->Byte_Set(mp+0,p_B);
MB->Byte_Set(mp+1,p_G);
MB->Byte_Set(mp+2,p_R);
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_PIXELGRID::RGB_Set(int p_X, int p_Y, JGC_RGBA *p_JGC_RGBA){
//----------------------------------------------------------------------------
this->RGB_Set(p_X, p_Y, p_JGC_RGBA->RGB_Get());
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_PIXELGRID::RGBA_Set(int p_X, int p_Y, int p_R, int p_G, int p_B, int p_A){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
MB->Byte_Set(mp+0,p_B);
MB->Byte_Set(mp+1,p_G);
MB->Byte_Set(mp+2,p_R);
MB->Byte_Set(mp+3,p_A);
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_PIXELGRID::RGBA_Set(int p_X, int p_Y, DWORD p_Value){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
MB->Dword_Set(mp,p_Value);
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_PIXELGRID::RGBA_Set(int p_X, int p_Y, JGC_RGBA *p_JGC_RGBA){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
MB->Dword_Set(mp,p_JGC_RGBA->RGBA_Get());
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
int JGC_PIXELGRID::Red_Get(int p_X, int p_Y){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
return MB->Byte_Get(mp+2);
}else{
return 0;
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
int JGC_PIXELGRID::Green_Get(int p_X, int p_Y){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
return MB->Byte_Get(mp+1);
}else{
return 0;
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
int JGC_PIXELGRID::Blue_Get(int p_X, int p_Y){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
return MB->Byte_Get(mp+0);
}else{
return 0;
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
int JGC_PIXELGRID::Alpha_Get(int p_X, int p_Y){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
return MB->Byte_Get(mp+3);
}else{
return 0;
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
DWORD JGC_PIXELGRID::RGB_Get(int p_X, int p_Y){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
return MB->Dword_Get(mp) & (DWORD)0x00FFFFFF;
} else {
return (DWORD)0;
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
DWORD JGC_PIXELGRID::RGBA_Get(int p_X, int p_Y){
//----------------------------------------------------------------------------
if(p_X<this->pvt_Width && p_Y<pvt_Height && p_X>=0 && p_Y>=0){
int mp=MemPos(p_X,p_Y);
return MB->Dword_Get(mp);
} else {
return (DWORD)0;
};
};
//----------------------------------------------------------------------------
Hope that's helpful.