* quick hack to hide the cursor in fullscreen
(TODO: do this after a time out) * quick hack to display bitmaps containing an alpha channel with a checker background (TODO: rework filters to be alpha channel aware and compose the checker background independently of the filter) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15886 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -168,6 +168,9 @@ ShowImageView::Pulse()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!fHasBorder) {
|
||||||
|
be_app->ObscureCursor();
|
||||||
|
}
|
||||||
#if DELAYED_SCALING
|
#if DELAYED_SCALING
|
||||||
if (fBitmap && (fScaleBilinear || fDither) && fScalingCountDown > 0) {
|
if (fBitmap && (fScaleBilinear || fDither) && fScalingCountDown > 0) {
|
||||||
fScalingCountDown --;
|
fScalingCountDown --;
|
||||||
@@ -188,6 +191,7 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
|||||||
InitPatterns();
|
InitPatterns();
|
||||||
fDither = false;
|
fDither = false;
|
||||||
fBitmap = NULL;
|
fBitmap = NULL;
|
||||||
|
fDisplayBitmap = NULL;
|
||||||
fSelBitmap = NULL;
|
fSelBitmap = NULL;
|
||||||
fDocumentIndex = 1;
|
fDocumentIndex = 1;
|
||||||
fDocumentCount = 1;
|
fDocumentCount = 1;
|
||||||
@@ -326,6 +330,11 @@ ShowImageView::DeleteBitmap()
|
|||||||
{
|
{
|
||||||
DeleteScaler();
|
DeleteScaler();
|
||||||
DeleteSelBitmap();
|
DeleteSelBitmap();
|
||||||
|
|
||||||
|
if (fDisplayBitmap != fBitmap)
|
||||||
|
delete fDisplayBitmap;
|
||||||
|
fDisplayBitmap = NULL;
|
||||||
|
|
||||||
delete fBitmap;
|
delete fBitmap;
|
||||||
fBitmap = NULL;
|
fBitmap = NULL;
|
||||||
}
|
}
|
||||||
@@ -336,6 +345,61 @@ void ShowImageView::DeleteSelBitmap()
|
|||||||
fSelBitmap = NULL;
|
fSelBitmap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rgb_color kAlphaLow = (rgb_color){ 0xbb, 0xbb, 0xbb, 0xff };
|
||||||
|
const rgb_color kAlphaHigh = (rgb_color){ 0xe0, 0xe0, 0xe0, 0xff };
|
||||||
|
|
||||||
|
inline void
|
||||||
|
blend_colors(uint8* d, uint8 r, uint8 g, uint8 b, uint8 a)
|
||||||
|
{
|
||||||
|
d[0] = ((b - d[0]) * a + (d[0] << 8)) >> 8;
|
||||||
|
d[1] = ((g - d[1]) * a + (d[1] << 8)) >> 8;
|
||||||
|
d[2] = ((r - d[2]) * a + (d[2] << 8)) >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
BBitmap*
|
||||||
|
compose_checker_background(const BBitmap* bitmap)
|
||||||
|
{
|
||||||
|
BBitmap* result = new (nothrow) BBitmap(bitmap);
|
||||||
|
if (result && !result->IsValid()) {
|
||||||
|
delete result;
|
||||||
|
result = NULL;
|
||||||
|
}
|
||||||
|
if (!result)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
uint8* bits = (uint8*)result->Bits();
|
||||||
|
uint32 bpr = result->BytesPerRow();
|
||||||
|
uint32 width = result->Bounds().IntegerWidth() + 1;
|
||||||
|
uint32 height = result->Bounds().IntegerHeight() + 1;
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < height; i++) {
|
||||||
|
uint8* p = bits;
|
||||||
|
for (uint32 x = 0; x < width; x++) {
|
||||||
|
uint8 alpha = p[3];
|
||||||
|
if (alpha < 255) {
|
||||||
|
p[3] = 255;
|
||||||
|
alpha = 255 - alpha;
|
||||||
|
if (x % 10 >= 5) {
|
||||||
|
if (i % 10 >= 5) {
|
||||||
|
blend_colors(p, kAlphaLow.red, kAlphaLow.green, kAlphaLow.blue, alpha);
|
||||||
|
} else {
|
||||||
|
blend_colors(p, kAlphaHigh.red, kAlphaHigh.green, kAlphaHigh.blue, alpha);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (i % 10 >= 5) {
|
||||||
|
blend_colors(p, kAlphaHigh.red, kAlphaHigh.green, kAlphaHigh.blue, alpha);
|
||||||
|
} else {
|
||||||
|
blend_colors(p, kAlphaLow.red, kAlphaLow.green, kAlphaLow.blue, alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p += 4;
|
||||||
|
}
|
||||||
|
bits += bpr;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ShowImageView::SetImage(const entry_ref *pref)
|
ShowImageView::SetImage(const entry_ref *pref)
|
||||||
{
|
{
|
||||||
@@ -382,9 +446,17 @@ ShowImageView::SetImage(const entry_ref *pref)
|
|||||||
fMakesSelection = false;
|
fMakesSelection = false;
|
||||||
DeleteBitmap();
|
DeleteBitmap();
|
||||||
fBitmap = newBitmap;
|
fBitmap = newBitmap;
|
||||||
|
fDisplayBitmap = NULL;
|
||||||
newBitmap = NULL;
|
newBitmap = NULL;
|
||||||
fCurrentRef = *pref;
|
fCurrentRef = *pref;
|
||||||
|
|
||||||
|
// prepare the display bitmap
|
||||||
|
if (fBitmap->ColorSpace() == B_RGBA32) {
|
||||||
|
fDisplayBitmap = compose_checker_background(fBitmap);
|
||||||
|
}
|
||||||
|
if (!fDisplayBitmap)
|
||||||
|
fDisplayBitmap = fBitmap;
|
||||||
|
|
||||||
// restore orientation
|
// restore orientation
|
||||||
int32 orientation;
|
int32 orientation;
|
||||||
fImageOrientation = k0;
|
fImageOrientation = k0;
|
||||||
@@ -517,8 +589,10 @@ ShowImageView::SetBorder(bool hasBorder)
|
|||||||
fHasBorder = hasBorder;
|
fHasBorder = hasBorder;
|
||||||
if (fHasBorder)
|
if (fHasBorder)
|
||||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
else
|
else {
|
||||||
SetLowColor(0, 0, 0, 255);
|
SetLowColor(0, 0, 0, 255);
|
||||||
|
be_app->ObscureCursor();
|
||||||
|
}
|
||||||
FixupScrollBars();
|
FixupScrollBars();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
@@ -795,7 +869,7 @@ ShowImageView::GetScaler(BRect rect)
|
|||||||
if (fScaler == NULL || !fScaler->Matches(rect, fDither)) {
|
if (fScaler == NULL || !fScaler->Matches(rect, fDither)) {
|
||||||
DeleteScaler();
|
DeleteScaler();
|
||||||
BMessenger msgr(this, Window());
|
BMessenger msgr(this, Window());
|
||||||
fScaler = new Scaler(fBitmap, rect, msgr, MSG_INVALIDATE, fDither);
|
fScaler = new Scaler(fDisplayBitmap, rect, msgr, MSG_INVALIDATE, fDither);
|
||||||
fScaler->Start();
|
fScaler->Start();
|
||||||
}
|
}
|
||||||
return fScaler;
|
return fScaler;
|
||||||
@@ -815,13 +889,15 @@ ShowImageView::DrawImage(BRect rect)
|
|||||||
#endif
|
#endif
|
||||||
if (scaler != NULL && !scaler->IsRunning()) {
|
if (scaler != NULL && !scaler->IsRunning()) {
|
||||||
BBitmap* bitmap = scaler->GetBitmap();
|
BBitmap* bitmap = scaler->GetBitmap();
|
||||||
|
|
||||||
if (bitmap) {
|
if (bitmap) {
|
||||||
DrawBitmap(bitmap, BPoint(rect.left, rect.top));
|
DrawBitmap(bitmap, BPoint(rect.left, rect.top));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawBitmap(fBitmap, fBitmap->Bounds(), rect);
|
|
||||||
|
DrawBitmap(fDisplayBitmap, fDisplayBitmap->Bounds(), rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -205,7 +205,9 @@ private:
|
|||||||
bool fDither; // dither the image
|
bool fDither; // dither the image
|
||||||
int32 fDocumentIndex; // of the image in the file
|
int32 fDocumentIndex; // of the image in the file
|
||||||
int32 fDocumentCount; // number of images in the file
|
int32 fDocumentCount; // number of images in the file
|
||||||
BBitmap *fBitmap; // to be displayed
|
BBitmap *fBitmap; // the original image
|
||||||
|
BBitmap *fDisplayBitmap; // the image to be displayed
|
||||||
|
// (== fBitmap if the bitmap can be displayed as is)
|
||||||
BBitmap *fSelBitmap; // the bitmap in the selection
|
BBitmap *fSelBitmap; // the bitmap in the selection
|
||||||
float fZoom; // factor to be used to display the image
|
float fZoom; // factor to be used to display the image
|
||||||
bool fScaleBilinear; // use bilinear scaling?
|
bool fScaleBilinear; // use bilinear scaling?
|
||||||
|
|||||||
Reference in New Issue
Block a user