Hello everybody:

I have done a function for painting in a DC with a bitmap as a pen.
I don't know if this is very efficient. Is there any other way to do this?

int Pintar(CDC * panel,RECT limites,POINT p,int r_trans,int g_trans,int b_trans)
{
//// draw the bitmap with identifier IDB_BITMAP1 in the p position of the panel
//// r_trans , g_trans and b_trans are the r g b values of the color that will be transparent
//// limites is a rect with the limits of the window of the panel

int i,j,l;
BITMAP bm;
CString t;

POINT punto;
HINSTANCE hInst=AfxGetInstanceHandle();
HBITMAP hbitmap=(HBITMAP)::LoadImage(hInst,MAKEINTRESOURCE(IDB_BITMAP1),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_DEFAULTSIZE);
GetObject(hbitmap, sizeof(BITMAP), (LPVOID) &bm);

int anchura,altura,nbpp,bsl;
anchura=bm.bmWidth;
altura=bm.bmHeight;
nbpp=bm.bmBitsPixel / 8; // bits por pixel , dividimos para bytes
bsl=bm.bmWidthBytes; // bytes por columna

unsigned char *data;
data=(unsigned char *)bm.bmBits;
int r,g,b;

for (i=0;i<altura;i++)
{
for (j=0,l=0;j<anchura;j++,l+=nbpp)
{

punto.x=p.x-(anchura/2)+j;
punto.y=p.y+(altura/2)-i;

b=*data++;
g=*data++;
r=*data++;

if (punto.x < 2 || punto.y < 2 || punto.y>limites.bottom-limites.top-2 || punto.x>limites.right-limites.left-2 ) continue;

if (r!=r_trans || g!=g_trans || b!=b_trans)
{

panel->SetPixel(punto,RGB(r,g,b));
}


}
}

return 0;
}


Thanks in advance
(sorry for my english)