MUY URGENTEEEEEEEE C++

MUY URGENTEEEEEEEE C++

Postby A&C » Sat Jun 30, 2007 11:52 pm

Amigos del FORO::

tengo este codigo en C++ creo ?? alguien lo aclare

COMO SE PUEDE INCLUIR CODIGO DE C++ EN FWH

miren::

//*********************************************************************\
* *
* Create24BPPDIBSection(HDC, int, int); *
* *
* Purpose: *
* Creates a 24 bit-per-pixel DIB section with the specified *
* width and height. *
* *
\*********************************************************************/

HBITMAP Create24BPPDIBSection(HDC hDC, int iWidth, int iHeight)
{
BITMAPINFO bmi;
HBITMAP hbm;
LPBYTE pBits;

// Initialize header to 0s.
ZeroMemory(&bmi, sizeof(bmi));

// Fill out the fields you care about.
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = iWidth;
bmi.bmiHeader.biHeight = iHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biCompression = BI_RGB;

// Create the surface.
hbm = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pBits, NULL, 0);

return(hbm);
}

/*********************************************************************\
* *
* BitmapsCompatible(LPBITMAP, LPBITMAP) *
* *
* Purpose: *
* Compares two bitmap structures to see if the surfaces are *
* the same width, height, and pixel format. *
* *
\*********************************************************************/

BOOL BitmapsCompatible(LPBITMAP lpbm1, LPBITMAP lpbm2)

{
if (lpbm1->bmBitsPixel != lpbm2->bmBitsPixel) return FALSE;
if (lpbm1->bmPlanes != lpbm2->bmPlanes) return FALSE;
if (lpbm1->bmWidth != lpbm2->bmWidth) return FALSE;
if (lpbm1->bmHeight != lpbm2->bmHeight) return FALSE;

return TRUE;
}

/*********************************************************************\
* *
* BOOL BlendImages(HBITMAP, HBITMAP, HBITMAP, DWORD); *
* *
* Purpose: *
* Blends two source images into a destination image *
* using a specified weighting value for the first source *
* image. *
* *
* Notes: *
* All HBITMAP parameters must be 24 bit-per-pixel DIB sections. *
* All HBITMAP parameters must have the same widths and heights. *
* Weighting values must be in the range of 0 .. 255. *
* *
\*********************************************************************/
BOOL BlendImages(HBITMAP hbmSrc1, HBITMAP hbmSrc2, HBITMAP hbmDst, DWORD dwWeight1)
{
BITMAP bmSrc1, bmSrc2, bmDst;
RGBTRIPLE *lprgbSrc1, *lprgbSrc2, *lprgbDst;
DWORD dwWidthBytes, dwWeight2;
int x, y;

// Only values between 0 and 255 are valid.
if (dwWeight1 > 255) return FALSE;

// Get weighting value for second source image.
dwWeight2 = 255-dwWeight1;

// Get information about the surfaces you were passed.
if (!GetObject(hbmSrc1, sizeof(BITMAP), &bmSrc1)) return FALSE;
if (!GetObject(hbmSrc2, sizeof(BITMAP), &bmSrc2)) return FALSE;
if (!GetObject(hbmDst, sizeof(BITMAP), &bmDst)) return FALSE;

// Make sure you have data that meets your requirements.
if (!BitmapsCompatible(&bmSrc1, &bmSrc2)) return FALSE;
if (!BitmapsCompatible(&bmSrc1, &bmDst)) return FALSE;
if (bmSrc1.bmBitsPixel != 24) return FALSE;
if (bmSrc1.bmPlanes != 1) return FALSE;
if (!bmSrc1.bmBits || !bmSrc2.bmBits || !bmDst.bmBits) return FALSE;

dwWidthBytes = bmDst.bmWidthBytes;

// Initialize the surface pointers.
lprgbSrc1 = bmSrc1.bmBits;
lprgbSrc2 = bmSrc2.bmBits;
lprgbDst = bmDst.bmBits;

for (y=0; y<bmDst.bmHeight; y++) {
for (x=0; x<bmDst.bmWidth; x++) {
lprgbDst[x].rgbtRed = (BYTE)((((DWORD)lprgbSrc1[x].rgbtRed * dwWeight1) +
((DWORD)lprgbSrc2[x].rgbtRed * dwWeight2)) >> 8);
lprgbDst[x].rgbtGreen = (BYTE)((((DWORD)lprgbSrc1[x].rgbtGreen * dwWeight1) +
((DWORD)lprgbSrc2[x].rgbtGreen * dwWeight2)) >> 8);
lprgbDst[x].rgbtBlue = (BYTE)((((DWORD)lprgbSrc1[x].rgbtBlue * dwWeight1) +
((DWORD)lprgbSrc2[x].rgbtBlue * dwWeight2)) >> 8);
}

// Move to next scan line.
lprgbSrc1 = (RGBTRIPLE *)((LPBYTE)lprgbSrc1 + dwWidthBytes);
lprgbSrc2 = (RGBTRIPLE *)((LPBYTE)lprgbSrc2 + dwWidthBytes);
lprgbDst = (RGBTRIPLE *)((LPBYTE)lprgbDst + dwWidthBytes);
}

return TRUE;
}


necesito poder usarle en FWH

GRACIAS POR LA AYUDA
Mi segundo amor es Programar
User avatar
A&C
 
Posts: 214
Joined: Sat Aug 19, 2006 1:37 pm
Location: Chile

Postby Antonio Linares » Sun Jul 01, 2007 6:43 am

Eso no parece ser C++ sino estandard C.

Revisa el directorio source/winapi de FWH en donde tienes montones de ejemplos de como implementar funciones en C :-)

O sino busca en estos foros por BEGINDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41456
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby antolin » Sun Jul 01, 2007 9:36 am

A&C, porque no te lees mi post de este mismo foro llamado "una de Verce", especialmente los ultimos mensajes donde explico como conseguí compilar una funcion en C++ adaptada de Clipper a Harbour. Por cierto las funciones que expones creo que pueden servir como C++ para Clipper
Suerte.
Saludos
antolin
 
Posts: 498
Joined: Thu May 10, 2007 8:30 pm
Location: Sevilla


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 150 guests