From 3da4d36c6ae016faaed64bd5eb3dd53e132b1147 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 11 Feb 2006 15:21:29 +0000 Subject: [PATCH] Added support for bitmaps in BPictures. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16348 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/ServerPicture.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/servers/app/ServerPicture.cpp b/src/servers/app/ServerPicture.cpp index 1ee81dc304..a01ce194b5 100644 --- a/src/servers/app/ServerPicture.cpp +++ b/src/servers/app/ServerPicture.cpp @@ -5,6 +5,7 @@ #include "ViewLayer.h" #include "WindowLayer.h" +#include #include #include @@ -178,18 +179,23 @@ static void draw_pixels(ViewLayer *view, BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data) { - /*BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, width - 1, height - 1), - flags | B_BITMAP_NO_SERVER_LINK, (color_space)pixelFormat); + // TODO: Review this + UtilityBitmap bitmap(BRect(0, 0, width - 1, height - 1), (color_space)pixelFormat, flags, bytesPerRow); - if (bitmap == NULL || bitmap->ImportBits(data, bytesPerRow * height, - bitmap->BytesPerRow(), 0, (color_space)pixelFormat) < B_OK) + if (!bitmap.IsValid()) return; + + uint8 *pixels = (uint8 *)data; + uint8 *destPixels = (uint8 *)bitmap.Bits(); + for (int32 h = 0; h < height; h++) { + memcpy(destPixels, pixels, bytesPerRow); + pixels += bytesPerRow; + destPixels += bytesPerRow; + } view->ConvertToScreenForDrawing(&dest); - view->Window()->GetDrawingEngine()->DrawBitmap(bitmap, src, dest, view->CurrentState()); - - delete bitmap;*/ + view->Window()->GetDrawingEngine()->DrawBitmap(&bitmap, src, dest, view->CurrentState()); }