diff --git a/preview/interfaces/BitmapPainter.cpp b/preview/interfaces/BitmapPainter.cpp index c44d5eb..e280f7d 100644 --- a/preview/interfaces/BitmapPainter.cpp +++ b/preview/interfaces/BitmapPainter.cpp @@ -297,19 +297,26 @@ namespace hal void BitmapPainterCanonical::DrawBitmap(infra::Bitmap& bitmap, infra::Point position, const infra::Bitmap& sourceBitmap, infra::Region boundingBox) { - assert(bitmap.pixelFormat == sourceBitmap.pixelFormat); auto bitmapDestination = infra::Region(position, sourceBitmap.size); auto boundedDestination = bitmapDestination & boundingBox; if (!boundedDestination.Empty()) { WaitUntilDrawingFinished(); - for (auto y = boundedDestination.Top() - bitmapDestination.Top(); y != boundedDestination.Bottom() - bitmapDestination.Top(); ++y) - for (auto x = boundedDestination.Left() - bitmapDestination.Left(); x != boundedDestination.Right() - bitmapDestination.Left(); ++x) - { - auto colour = sourceBitmap.PixelColour(infra::Point(x, y)); - DrawPixel(bitmap, bitmapDestination.TopLeft() + infra::Vector(x, y), colour); - } + if (bitmap.pixelFormat == infra::PixelFormat::blackandwhite) + for (auto y = boundedDestination.Top() - bitmapDestination.Top(); y != boundedDestination.Bottom() - bitmapDestination.Top(); ++y) + for (auto x = boundedDestination.Left() - bitmapDestination.Left(); x != boundedDestination.Right() - bitmapDestination.Left(); ++x) + { + bool colour = sourceBitmap.BlackAndWhitePixel(infra::Point(x, y)); + DrawPixel(bitmap, bitmapDestination.TopLeft() + infra::Vector(x, y), colour); + } + else + for (auto y = boundedDestination.Top() - bitmapDestination.Top(); y != boundedDestination.Bottom() - bitmapDestination.Top(); ++y) + for (auto x = boundedDestination.Left() - bitmapDestination.Left(); x != boundedDestination.Right() - bitmapDestination.Left(); ++x) + { + auto colour = sourceBitmap.PixelColour(infra::Point(x, y)); + DrawPixel(bitmap, bitmapDestination.TopLeft() + infra::Vector(x, y), colour); + } } } diff --git a/preview/views/ViewRotating.cpp b/preview/views/ViewRotating.cpp index 19be01d..34761f3 100644 --- a/preview/views/ViewRotating.cpp +++ b/preview/views/ViewRotating.cpp @@ -36,7 +36,8 @@ namespace services if (subView) { subView->ResetSize(); - ResizeWithoutTrigger(infra::RotatedVectorInRegion(subView->ViewRegion().Size(), angle, rotatedRegion)); + rotatedRegion = infra::RotatedRegionInRegion(subView->ViewRegion(), -angle, subView->ViewRegion()); + ResizeWithoutTrigger(rotatedRegion.Size()); } else ResizeWithoutTrigger(infra::Vector()); @@ -125,17 +126,17 @@ namespace services void ViewRotating::CanvasRotating::DrawBitmap(infra::Point position, const infra::Bitmap& sourceBitmap, infra::Region boundingBox) { - canvas.DrawBitmap(Rotated(position), sourceBitmap, Rotated(boundingBox)); + canvas.DrawBitmap(Rotated(infra::Region(position, sourceBitmap.size)).TopLeft(), sourceBitmap, Rotated(boundingBox)); } void ViewRotating::CanvasRotating::DrawTransparentBitmap(infra::Point position, const infra::Bitmap& sourceBitmap, uint32_t transparencyColour, infra::Region boundingBox) { - canvas.DrawTransparentBitmap(Rotated(position), sourceBitmap, transparencyColour, Rotated(boundingBox)); + canvas.DrawTransparentBitmap(Rotated(infra::Region(position, sourceBitmap.size)).TopLeft(), sourceBitmap, transparencyColour, Rotated(boundingBox)); } void ViewRotating::CanvasRotating::DrawIcon(infra::Point position, const infra::Bitmap& sourceBitmap, infra::Colour colour, infra::Region boundingBox) { - canvas.DrawIcon(Rotated(position), sourceBitmap, colour, Rotated(boundingBox)); + canvas.DrawIcon(Rotated(infra::Region(position, sourceBitmap.size)).TopLeft(), sourceBitmap, colour, Rotated(boundingBox)); } void ViewRotating::CanvasRotating::DrawString(infra::Point position, infra::BoundedConstString string, const infra::Font& font, infra::Colour colour, infra::RightAngle direction, infra::Region boundingBox)