¿Quién sabe? alphablending 2 bitmaps
-
There 2 32bpp bitmaps with some images: bitmap1 bitmap2 and graphics object g1 created from bitmap1 I set individualy alpha values in bitmap2 using LockBits:
Gdiplus::BitmapData bitmapData; Gdiplus::Status s = pBitmap->LockBits(&Gdiplus::Rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()), Gdiplus::ImageLockModeWrite | Gdiplus::ImageLockModeRead, PixelFormat32bppRGB, &bitmapData); if (s == Gdiplus::Ok) { unsigned int\* pPixels = (unsigned int \*)bitmapData.Scan0; for (unsigned int i = 0; i < bitmapData.Height; i++) { for (unsigned int j = 0; j < bitmapData.Width; j++) { if (mask(i, j) > 0) pPixels\[j\] &= 0xFFFFFFFF; else pPixels\[j\] = 0x00FFFFFF; } pPixels += bitmapData.Stride / 4; } pBitmap->UnlockBits(&bitmapData); }
And then draw it on bitmap1 using g1. But the alpha blending does not happen?
chesnokov
-
There 2 32bpp bitmaps with some images: bitmap1 bitmap2 and graphics object g1 created from bitmap1 I set individualy alpha values in bitmap2 using LockBits:
Gdiplus::BitmapData bitmapData; Gdiplus::Status s = pBitmap->LockBits(&Gdiplus::Rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()), Gdiplus::ImageLockModeWrite | Gdiplus::ImageLockModeRead, PixelFormat32bppRGB, &bitmapData); if (s == Gdiplus::Ok) { unsigned int\* pPixels = (unsigned int \*)bitmapData.Scan0; for (unsigned int i = 0; i < bitmapData.Height; i++) { for (unsigned int j = 0; j < bitmapData.Width; j++) { if (mask(i, j) > 0) pPixels\[j\] &= 0xFFFFFFFF; else pPixels\[j\] = 0x00FFFFFF; } pPixels += bitmapData.Stride / 4; } pBitmap->UnlockBits(&bitmapData); }
And then draw it on bitmap1 using g1. But the alpha blending does not happen?
chesnokov
I don't see where you're doing any alpha blending. Alpha blending would mean blending the values of two bitmaps. What are you trying to do ? Also, have you stepped through the code to see if mask(i,j) is ever > 0 ? I assume that mask is a method, calling a method for every pixel will really slow your code down.
Christian Graus Driven to the arms of OSX by Vista.
-
I don't see where you're doing any alpha blending. Alpha blending would mean blending the values of two bitmaps. What are you trying to do ? Also, have you stepped through the code to see if mask(i,j) is ever > 0 ? I assume that mask is a method, calling a method for every pixel will really slow your code down.
Christian Graus Driven to the arms of OSX by Vista.
sure. mask is a unsigned int version of http://www.codeproject.com/KB/recipes/SSE_optimized_2D_vector.aspx[^] it is inline operator(y,x) for m_data[y][x]. it has print() function so you can view its contents before hand. I need to turn off some pixels in bitmap2 by setting their A values to 0, so if you draw it to bitmap2, the pixels with A = 0 will not affect bitmap1 pixels
chesnokov
-
I don't see where you're doing any alpha blending. Alpha blending would mean blending the values of two bitmaps. What are you trying to do ? Also, have you stepped through the code to see if mask(i,j) is ever > 0 ? I assume that mask is a method, calling a method for every pixel will really slow your code down.
Christian Graus Driven to the arms of OSX by Vista.
BTW you work in vet telemedicine, do they collect/transfer ECGs? http://www.codeproject.com/KB/library/ECG_annotation_lib.aspx[^] It might be useful for some wealthy clients of having a dog or a cat with ECG recorder say predicting PAF onset?
Чесноков
-
There 2 32bpp bitmaps with some images: bitmap1 bitmap2 and graphics object g1 created from bitmap1 I set individualy alpha values in bitmap2 using LockBits:
Gdiplus::BitmapData bitmapData; Gdiplus::Status s = pBitmap->LockBits(&Gdiplus::Rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()), Gdiplus::ImageLockModeWrite | Gdiplus::ImageLockModeRead, PixelFormat32bppRGB, &bitmapData); if (s == Gdiplus::Ok) { unsigned int\* pPixels = (unsigned int \*)bitmapData.Scan0; for (unsigned int i = 0; i < bitmapData.Height; i++) { for (unsigned int j = 0; j < bitmapData.Width; j++) { if (mask(i, j) > 0) pPixels\[j\] &= 0xFFFFFFFF; else pPixels\[j\] = 0x00FFFFFF; } pPixels += bitmapData.Stride / 4; } pBitmap->UnlockBits(&bitmapData); }
And then draw it on bitmap1 using g1. But the alpha blending does not happen?
chesnokov
Shouldn´t the PixelFormat be PixelFormat32bppARGB instead of PixelFormat32bppRGB?