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)) >> ;
lprgbDst[x].rgbtGreen = (BYTE)((((DWORD)lprgbSrc1[x].rgbtGreen * dwWeight1) +
((DWORD)lprgbSrc2[x].rgbtGreen * dwWeight2)) >> ;
lprgbDst[x].rgbtBlue = (BYTE)((((DWORD)lprgbSrc1[x].rgbtBlue * dwWeight1) +
((DWORD)lprgbSrc2[x].rgbtBlue * dwWeight2)) >> ;
}
// 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
MUY URGENTEEEEEEEE C++
MUY URGENTEEEEEEEE C++
Mi segundo amor es Programar
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: