diff options
Diffstat (limited to 'win32/PlatWin.cxx')
| -rw-r--r-- | win32/PlatWin.cxx | 27 | 
1 files changed, 6 insertions, 21 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 6e5859ca3..fadc7d0f0 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -780,15 +780,10 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig  			HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem);  			for (int y=height-1; y>=0; y--) { -				for (int x=0; x<width; x++) { -					unsigned char *pixel = static_cast<unsigned char *>(image) + (y*width+x) * 4; -					const unsigned char alpha = pixelsImage[3]; -					// Input is RGBA, output is BGRA with premultiplied alpha -					pixel[2] = static_cast<unsigned char>((*pixelsImage++) * alpha / 255); -					pixel[1] = static_cast<unsigned char>((*pixelsImage++) * alpha / 255); -					pixel[0] = static_cast<unsigned char>((*pixelsImage++) * alpha / 255); -					pixel[3] = *pixelsImage++; -				} +				// Bits flipped vertically +				unsigned char *pixel = static_cast<unsigned char *>(image) + RGBAImage::bytesPerPixel * y * width; +				RGBAImage::BGRAFromRGBA(pixel, pixelsImage, width); +				pixelsImage += RGBAImage::bytesPerPixel * width;  			}  			const BLENDFUNCTION merge = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; @@ -1445,18 +1440,8 @@ void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsig  			rc.top += std::floor((rc.Height() - height) / 2);  		rc.bottom = rc.top + height; -		std::vector<unsigned char> image(height * width * 4); -		for (int yPixel=0; yPixel<height; yPixel++) { -			for (int xPixel = 0; xPixel<width; xPixel++) { -				unsigned char *pixel = &image[0] + (yPixel*width + xPixel) * 4; -				const unsigned char alpha = pixelsImage[3]; -				// Input is RGBA, output is BGRA with premultiplied alpha -				pixel[2] = (*pixelsImage++) * alpha / 255; -				pixel[1] = (*pixelsImage++) * alpha / 255; -				pixel[0] = (*pixelsImage++) * alpha / 255; -				pixel[3] = *pixelsImage++; -			} -		} +		std::vector<unsigned char> image(RGBAImage::bytesPerPixel * height * width); +		RGBAImage::BGRAFromRGBA(image.data(), pixelsImage, static_cast<ptrdiff_t>(height) * width);  		ID2D1Bitmap *bitmap = nullptr;  		const D2D1_SIZE_U size = D2D1::SizeU(width, height);  | 
