diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index b9a318bab9..e5d40b266e 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -1411,11 +1411,45 @@ ShowImageView::PageCount() return fDocumentCount; } +void +ShowImageView::AddWhiteRect(BRect &rect) +{ + // Paint white rectangle, using rect, into the background image + BView view(fBitmap->Bounds(), NULL, B_FOLLOW_NONE, B_WILL_DRAW); + BBitmap *bitmap = new BBitmap(fBitmap->Bounds(), fBitmap->ColorSpace(), true); + if (bitmap == NULL) + return; + + if (bitmap->Lock()) { + bitmap->AddChild(&view); + view.DrawBitmap(fBitmap, fBitmap->Bounds()); + + view.FillRect(rect, B_SOLID_LOW); + // draw white rect + + view.Sync(); + bitmap->RemoveChild(&view); + bitmap->Unlock(); + + DeleteBitmap(); + fBitmap = bitmap; + } else + delete bitmap; +} + void ShowImageView::Cut() { + BRect rect = fSelectionRect; + bool bCutBackground = (fSelBitmap) ? false : true; + CopySelectionToClipboard(); ClearSelection(); + + if (bCutBackground) + // If the user hasn't dragged the selection, + // paint a white rectangle where the selection was + AddWhiteRect(rect); } void diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h index 3acd38dc54..92a50701ca 100644 --- a/src/apps/showimage/ShowImageView.h +++ b/src/apps/showimage/ShowImageView.h @@ -129,6 +129,7 @@ private: void AnimateSelection(bool a); void Notify(const char* status); void AddToRecentDocuments(); + void AddWhiteRect(BRect &rect); void GetSelMergeRects(BRect &srcBits, BRect &destRect); void MergeSelection(); void DeleteScaler();