Coding style changes, no functional change.
Hope all's OK, Filter.h is still mostly untouched as it's quite messy with many exessive commenting.
This commit is contained in:
+135
-84
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku.
|
* Copyright 2003-2006, Haiku, Inc. All rights reserved.
|
||||||
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserved.
|
||||||
* Copyright 2006 Bernd Korz. All Rights Reserved
|
* Copyright 2006 Bernd Korz. All Rights Reserved
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
@@ -21,29 +21,32 @@
|
|||||||
|
|
||||||
|
|
||||||
// Implementation of FilterThread
|
// Implementation of FilterThread
|
||||||
FilterThread::FilterThread(Filter* filter, int32 i, int32 n, bool runInCurrentThread)
|
FilterThread::FilterThread(Filter* filter, int32 i, int32 n,
|
||||||
: fFilter(filter)
|
bool runInCurrentThread)
|
||||||
, fI(i)
|
: fFilter(filter),
|
||||||
, fN(n)
|
fI(i),
|
||||||
|
fN(n)
|
||||||
{
|
{
|
||||||
if (runInCurrentThread) {
|
if (runInCurrentThread)
|
||||||
Run();
|
Run();
|
||||||
} else {
|
else {
|
||||||
thread_id tid;
|
thread_id tid;
|
||||||
tid = spawn_thread(worker_thread, "filter", suggest_thread_priority(B_STATUS_RENDERING), this);
|
tid = spawn_thread(worker_thread, "filter",
|
||||||
if (tid >= 0) {
|
suggest_thread_priority(B_STATUS_RENDERING), this);
|
||||||
|
if (tid >= 0)
|
||||||
resume_thread(tid);
|
resume_thread(tid);
|
||||||
} else {
|
else
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
FilterThread::~FilterThread()
|
FilterThread::~FilterThread()
|
||||||
{
|
{
|
||||||
fFilter->FilterThreadDone();
|
fFilter->FilterThreadDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
FilterThread::worker_thread(void* data)
|
FilterThread::worker_thread(void* data)
|
||||||
{
|
{
|
||||||
@@ -51,6 +54,7 @@ FilterThread::worker_thread(void* data)
|
|||||||
return thread->Run();
|
return thread->Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
FilterThread::Run()
|
FilterThread::Run()
|
||||||
{
|
{
|
||||||
@@ -67,24 +71,25 @@ FilterThread::Run()
|
|||||||
new FilterThread(fFilter, i, fN);
|
new FilterThread(fFilter, i, fN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fFilter->GetBitmap()) {
|
if (fFilter->GetBitmap())
|
||||||
fFilter->Run(fI, fN);
|
fFilter->Run(fI, fN);
|
||||||
}
|
|
||||||
delete this;
|
delete this;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementation of Filter
|
// Implementation of Filter
|
||||||
Filter::Filter(BBitmap* image, BMessenger listener, uint32 what)
|
Filter::Filter(BBitmap* image, BMessenger listener, uint32 what)
|
||||||
: fListener(listener)
|
:
|
||||||
, fWhat(what)
|
fListener(listener),
|
||||||
, fStarted(false)
|
fWhat(what),
|
||||||
, fN(0)
|
fStarted(false),
|
||||||
, fNumberOfThreads(0)
|
fN(0),
|
||||||
, fIsRunning(false)
|
fNumberOfThreads(0),
|
||||||
, fSrcImage(image)
|
fIsRunning(false),
|
||||||
, fDestImageInitialized(false)
|
fSrcImage(image),
|
||||||
, fDestImage(NULL)
|
fDestImageInitialized(false),
|
||||||
|
fDestImage(NULL)
|
||||||
{
|
{
|
||||||
fCPUCount = NumberOfActiveCPUs();
|
fCPUCount = NumberOfActiveCPUs();
|
||||||
|
|
||||||
@@ -95,12 +100,14 @@ Filter::Filter(BBitmap* image, BMessenger listener, uint32 what)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Filter::~Filter()
|
Filter::~Filter()
|
||||||
{
|
{
|
||||||
delete fDestImage;
|
delete fDestImage;
|
||||||
delete_sem(fWaitForThreads);
|
delete_sem(fWaitForThreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
Filter::GetBitmap()
|
Filter::GetBitmap()
|
||||||
{
|
{
|
||||||
@@ -111,6 +118,7 @@ Filter::GetBitmap()
|
|||||||
return fDestImage;
|
return fDestImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
Filter::DetachBitmap()
|
Filter::DetachBitmap()
|
||||||
{
|
{
|
||||||
@@ -119,6 +127,7 @@ Filter::DetachBitmap()
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Filter::Start(bool async)
|
Filter::Start(bool async)
|
||||||
{
|
{
|
||||||
@@ -136,10 +145,10 @@ Filter::Start(bool async)
|
|||||||
// start first filter thread
|
// start first filter thread
|
||||||
new FilterThread(this, 0, fN, !async);
|
new FilterThread(this, 0, fN, !async);
|
||||||
|
|
||||||
if (!async) {
|
if (!async)
|
||||||
Wait();
|
Wait();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Filter::Wait()
|
Filter::Wait()
|
||||||
@@ -152,6 +161,7 @@ Filter::Wait()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Filter::Stop()
|
Filter::Stop()
|
||||||
{
|
{
|
||||||
@@ -160,17 +170,20 @@ Filter::Stop()
|
|||||||
Wait();
|
Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Filter::IsRunning() const
|
Filter::IsRunning() const
|
||||||
{
|
{
|
||||||
return fIsRunning;
|
return fIsRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Filter::Completed()
|
Filter::Completed()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Filter::FilterThreadDone()
|
Filter::FilterThreadDone()
|
||||||
{
|
{
|
||||||
@@ -179,14 +192,15 @@ Filter::FilterThreadDone()
|
|||||||
delete fStopWatch; fStopWatch = NULL;
|
delete fStopWatch; fStopWatch = NULL;
|
||||||
#endif
|
#endif
|
||||||
Completed();
|
Completed();
|
||||||
if (fIsRunning) {
|
if (fIsRunning)
|
||||||
fListener.SendMessage(fWhat);
|
fListener.SendMessage(fWhat);
|
||||||
}
|
|
||||||
fIsRunning = false;
|
fIsRunning = false;
|
||||||
}
|
}
|
||||||
release_sem(fWaitForThreads);
|
release_sem(fWaitForThreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Filter::FilterThreadInitFailed()
|
Filter::FilterThreadInitFailed()
|
||||||
{
|
{
|
||||||
@@ -197,38 +211,43 @@ Filter::FilterThreadInitFailed()
|
|||||||
release_sem_etc(fWaitForThreads, fN, 0);
|
release_sem_etc(fWaitForThreads, fN, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Filter::IsBitmapValid(BBitmap* bitmap) const
|
Filter::IsBitmapValid(BBitmap* bitmap) const
|
||||||
{
|
{
|
||||||
return bitmap != NULL && bitmap->InitCheck() == B_OK && bitmap->IsValid();
|
return bitmap != NULL && bitmap->InitCheck() == B_OK && bitmap->IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
Filter::NumberOfThreads()
|
Filter::NumberOfThreads()
|
||||||
{
|
{
|
||||||
const int32 units = GetNumberOfUnits();
|
const int32 units = GetNumberOfUnits();
|
||||||
int32 n;
|
int32 n;
|
||||||
n = units / 32; // at least 32 units per CPU
|
n = units / 32; // at least 32 units per CPU
|
||||||
if (n > CPUCount()) {
|
if (n > CPUCount())
|
||||||
n = CPUCount();
|
n = CPUCount();
|
||||||
} else if (n <= 0) {
|
else if (n <= 0)
|
||||||
n = 1; // at least one thread!
|
n = 1; // at least one thread!
|
||||||
}
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
Filter::GetSrcImage()
|
Filter::GetSrcImage()
|
||||||
{
|
{
|
||||||
return fSrcImage;
|
return fSrcImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
Filter::GetDestImage()
|
Filter::GetDestImage()
|
||||||
{
|
{
|
||||||
return fDestImage;
|
return fDestImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
Filter::NumberOfActiveCPUs() const
|
Filter::NumberOfActiveCPUs() const
|
||||||
{
|
{
|
||||||
@@ -247,15 +266,19 @@ Filter::NumberOfActiveCPUs() const
|
|||||||
return cpuCount;
|
return cpuCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Implementation of (bilinear) Scaler
|
// Implementation of (bilinear) Scaler
|
||||||
Scaler::Scaler(BBitmap* image, BRect rect, BMessenger listener, uint32 what, bool dither)
|
Scaler::Scaler(BBitmap* image, BRect rect, BMessenger listener, uint32 what,
|
||||||
: Filter(image, listener, what)
|
bool dither)
|
||||||
, fScaledImage(NULL)
|
:
|
||||||
, fRect(rect)
|
Filter(image, listener, what),
|
||||||
, fDither(dither)
|
fScaledImage(NULL),
|
||||||
|
fRect(rect),
|
||||||
|
fDither(dither)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Scaler::~Scaler()
|
Scaler::~Scaler()
|
||||||
{
|
{
|
||||||
if (GetDestImage() != fScaledImage) {
|
if (GetDestImage() != fScaledImage) {
|
||||||
@@ -264,13 +287,17 @@ Scaler::~Scaler()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
Scaler::CreateDestImage(BBitmap* srcImage)
|
Scaler::CreateDestImage(BBitmap* srcImage)
|
||||||
{
|
{
|
||||||
if (srcImage == NULL || (srcImage->ColorSpace() != B_RGB32 && srcImage->ColorSpace() != B_RGBA32)) return NULL;
|
if (srcImage == NULL || (srcImage->ColorSpace() != B_RGB32
|
||||||
|
&& srcImage->ColorSpace() != B_RGBA32))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
BRect dest(0, 0, fRect.IntegerWidth(), fRect.IntegerHeight());
|
BRect dest(0, 0, fRect.IntegerWidth(), fRect.IntegerHeight());
|
||||||
BBitmap* destImage = new BBitmap(dest, fDither ? B_CMAP8 : srcImage->ColorSpace());
|
BBitmap* destImage = new BBitmap(dest,
|
||||||
|
fDither ? B_CMAP8 : srcImage->ColorSpace());
|
||||||
|
|
||||||
if (!IsBitmapValid(destImage)) {
|
if (!IsBitmapValid(destImage)) {
|
||||||
delete destImage;
|
delete destImage;
|
||||||
@@ -287,19 +314,19 @@ Scaler::CreateDestImage(BBitmap* srcImage)
|
|||||||
fScaledImage = NULL;
|
fScaledImage = NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
fScaledImage = destImage;
|
fScaledImage = destImage;
|
||||||
}
|
|
||||||
|
|
||||||
return destImage;
|
return destImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Scaler::Matches(BRect rect, bool dither) const
|
Scaler::Matches(BRect rect, bool dither) const
|
||||||
{
|
{
|
||||||
return fRect.IntegerWidth() == rect.IntegerWidth() &&
|
return fRect.IntegerWidth() == rect.IntegerWidth()
|
||||||
fRect.IntegerHeight() == rect.IntegerHeight() &&
|
&& fRect.IntegerHeight() == rect.IntegerHeight()
|
||||||
fDither == dither;
|
&& fDither == dither;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -310,6 +337,7 @@ typedef struct {
|
|||||||
float alpha1;
|
float alpha1;
|
||||||
} ColumnData;
|
} ColumnData;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Scaler::ScaleBilinear(intType fromRow, int32 toRow)
|
Scaler::ScaleBilinear(intType fromRow, int32 toRow)
|
||||||
{
|
{
|
||||||
@@ -357,11 +385,11 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow)
|
|||||||
intType srcRow;
|
intType srcRow;
|
||||||
float alpha0, alpha1;
|
float alpha0, alpha1;
|
||||||
|
|
||||||
if (destH == 0) {
|
if (destH == 0)
|
||||||
row = 0;
|
row = 0;
|
||||||
} else {
|
else
|
||||||
row = (float)y * (float)srcH / (float)destH;
|
row = (float)y * (float)srcH / (float)destH;
|
||||||
}
|
|
||||||
srcRow = (intType)row;
|
srcRow = (intType)row;
|
||||||
alpha1 = row - srcRow;
|
alpha1 = row - srcRow;
|
||||||
alpha0 = 1.0 - alpha1;
|
alpha0 = 1.0 - alpha1;
|
||||||
@@ -434,6 +462,7 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow)
|
|||||||
delete[] columnData;
|
delete[] columnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Scale bilinear using fixed point calculations
|
// Scale bilinear using fixed point calculations
|
||||||
// Is already more than two times faster than floating point version
|
// Is already more than two times faster than floating point version
|
||||||
// on AMD Athlon 1 GHz and Dual Intel Pentium III 866 MHz.
|
// on AMD Athlon 1 GHz and Dual Intel Pentium III 866 MHz.
|
||||||
@@ -444,6 +473,7 @@ typedef struct {
|
|||||||
fixed_point alpha1;
|
fixed_point alpha1;
|
||||||
} ColumnDataFP;
|
} ColumnDataFP;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Scaler::ScaleBilinearFP(intType fromRow, int32 toRow)
|
Scaler::ScaleBilinearFP(intType fromRow, int32 toRow)
|
||||||
{
|
{
|
||||||
@@ -483,7 +513,8 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow)
|
|||||||
columnData = new ColumnDataFP[destW];
|
columnData = new ColumnDataFP[destW];
|
||||||
cd = columnData;
|
cd = columnData;
|
||||||
for (i = 0; i < destW; i++, cd++) {
|
for (i = 0; i < destW; i++, cd++) {
|
||||||
fixed_point column = to_fixed_point(i) * (long_fixed_point)fpSrcW / fpDestW;
|
fixed_point column = to_fixed_point(i) * (long_fixed_point)fpSrcW
|
||||||
|
/ fpDestW;
|
||||||
cd->srcColumn = from_fixed_point(column);
|
cd->srcColumn = from_fixed_point(column);
|
||||||
cd->alpha1 = tail_value(column); // weigth for left pixel value
|
cd->alpha1 = tail_value(column); // weigth for left pixel value
|
||||||
cd->alpha0 = kFPOne - cd->alpha1; // weigth for right pixel value
|
cd->alpha0 = kFPOne - cd->alpha1; // weigth for right pixel value
|
||||||
@@ -496,11 +527,11 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow)
|
|||||||
intType srcRow;
|
intType srcRow;
|
||||||
fixed_point alpha0, alpha1;
|
fixed_point alpha0, alpha1;
|
||||||
|
|
||||||
if (fpDestH == 0) {
|
if (fpDestH == 0)
|
||||||
row = 0;
|
row = 0;
|
||||||
} else {
|
else
|
||||||
row = to_fixed_point(y) * (long_fixed_point)fpSrcH / fpDestH;
|
row = to_fixed_point(y) * (long_fixed_point)fpSrcH / fpDestH;
|
||||||
}
|
|
||||||
srcRow = from_fixed_point(row);
|
srcRow = from_fixed_point(row);
|
||||||
alpha1 = tail_value(row); // weight for row y + 1
|
alpha1 = tail_value(row); // weight for row y + 1
|
||||||
alpha0 = kFPOne - alpha1; // weight for row y
|
alpha0 = kFPOne - alpha1; // weight for row y
|
||||||
@@ -566,14 +597,15 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow)
|
|||||||
destData[2] = a[2];
|
destData[2] = a[2];
|
||||||
destData[3] = a[3];
|
destData[3] = a[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] columnData;
|
delete[] columnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Scaler::RowValues(float* sum, const uchar* src, intType srcW, intType fromX, intType toX, const float a0X, const float a1X, const int32 kBPP)
|
Scaler::RowValues(float* sum, const uchar* src, intType srcW, intType fromX,
|
||||||
|
intType toX, const float a0X, const float a1X, const int32 kBPP)
|
||||||
{
|
{
|
||||||
sum[0] = a0X * src[0];
|
sum[0] = a0X * src[0];
|
||||||
sum[1] = a0X * src[1];
|
sum[1] = a0X * src[1];
|
||||||
@@ -594,6 +626,7 @@ Scaler::RowValues(float* sum, const uchar* src, intType srcW, intType fromX, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32 from;
|
int32 from;
|
||||||
int32 to;
|
int32 to;
|
||||||
@@ -601,6 +634,7 @@ typedef struct {
|
|||||||
float alpha1;
|
float alpha1;
|
||||||
} DownScaleColumnData;
|
} DownScaleColumnData;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Scaler::DownScaleBilinear(intType fromRow, int32 toRow)
|
Scaler::DownScaleBilinear(intType fromRow, int32 toRow)
|
||||||
{
|
{
|
||||||
@@ -706,6 +740,7 @@ Scaler::DownScaleBilinear(intType fromRow, int32 toRow)
|
|||||||
delete[] columnData;
|
delete[] columnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Flyod-Steinberg Dithering
|
// Flyod-Steinberg Dithering
|
||||||
// Filter (distribution of error to adjacent pixels, X is current pixel):
|
// Filter (distribution of error to adjacent pixels, X is current pixel):
|
||||||
// 0 X 7
|
// 0 X 7
|
||||||
@@ -715,6 +750,7 @@ typedef struct {
|
|||||||
intType error[3];
|
intType error[3];
|
||||||
} DitheringColumnData;
|
} DitheringColumnData;
|
||||||
|
|
||||||
|
|
||||||
uchar
|
uchar
|
||||||
Scaler::Limit(intType value)
|
Scaler::Limit(intType value)
|
||||||
{
|
{
|
||||||
@@ -726,6 +762,7 @@ Scaler::Limit(intType value)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Scaler::Dither(int32 fromRow, int32 toRow)
|
Scaler::Dither(int32 fromRow, int32 toRow)
|
||||||
{
|
{
|
||||||
@@ -778,7 +815,8 @@ Scaler::Dither(int32 fromRow, int32 toRow)
|
|||||||
|
|
||||||
srcDataRow = srcBits + fromRow * srcBPR;
|
srcDataRow = srcBits + fromRow * srcBPR;
|
||||||
destDataRow = destBits + fromRow * destBPR;
|
destDataRow = destBits + fromRow * destBPR;
|
||||||
for (y = fromRow; IsRunning() && y <= toRow; y ++, srcDataRow += srcBPR, destDataRow += destBPR) {
|
for (y = fromRow; IsRunning() && y <= toRow; y++, srcDataRow += srcBPR,
|
||||||
|
destDataRow += destBPR) {
|
||||||
// left to right
|
// left to right
|
||||||
error[0] = error[1] = error[2] = 0;
|
error[0] = error[1] = error[2] = 0;
|
||||||
srcData = srcDataRow;
|
srcData = srcDataRow;
|
||||||
@@ -879,12 +917,14 @@ Scaler::Dither(int32 fromRow, int32 toRow)
|
|||||||
delete[] columnData0;
|
delete[] columnData0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
Scaler::GetNumberOfUnits()
|
Scaler::GetNumberOfUnits()
|
||||||
{
|
{
|
||||||
return fRect.IntegerHeight() + 1;
|
return fRect.IntegerHeight() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Scaler::Run(int32 i, int32 n)
|
Scaler::Run(int32 i, int32 n)
|
||||||
{
|
{
|
||||||
@@ -892,43 +932,47 @@ Scaler::Run(int32 i, int32 n)
|
|||||||
imageHeight = GetDestImage()->Bounds().IntegerHeight() + 1;
|
imageHeight = GetDestImage()->Bounds().IntegerHeight() + 1;
|
||||||
height = imageHeight / n;
|
height = imageHeight / n;
|
||||||
from = i * height;
|
from = i * height;
|
||||||
if (i+1 == n) {
|
if (i + 1 == n)
|
||||||
to = imageHeight - 1;
|
to = imageHeight - 1;
|
||||||
} else {
|
else
|
||||||
to = from + height - 1;
|
to = from + height - 1;
|
||||||
}
|
|
||||||
if (GetDestImage()->Bounds().Width() >= GetSrcImage()->Bounds().Width()) {
|
if (GetDestImage()->Bounds().Width() >= GetSrcImage()->Bounds().Width())
|
||||||
ScaleBilinearFP(from, to);
|
ScaleBilinearFP(from, to);
|
||||||
} else {
|
else
|
||||||
DownScaleBilinear(from, to);
|
DownScaleBilinear(from, to);
|
||||||
}
|
|
||||||
if (fDither) {
|
if (fDither)
|
||||||
Dither(from, to);
|
Dither(from, to);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Scaler::Completed()
|
Scaler::Completed()
|
||||||
{
|
{
|
||||||
if (GetDestImage() != fScaledImage) {
|
if (GetDestImage() != fScaledImage)
|
||||||
delete fScaledImage;
|
delete fScaledImage;
|
||||||
}
|
|
||||||
fScaledImage = NULL;
|
fScaledImage = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementation of ImageProcessor
|
|
||||||
ImageProcessor::ImageProcessor(enum operation op, BBitmap* image, BMessenger listener, uint32 what)
|
|
||||||
: Filter(image, listener, what)
|
|
||||||
, fOp(op)
|
|
||||||
, fBPP(0)
|
|
||||||
, fWidth(0)
|
|
||||||
, fHeight(0)
|
|
||||||
, fSrcBPR(0)
|
|
||||||
, fDestBPR(0)
|
|
||||||
|
|
||||||
|
// Implementation of ImageProcessor
|
||||||
|
ImageProcessor::ImageProcessor(enum operation op, BBitmap* image,
|
||||||
|
BMessenger listener, uint32 what)
|
||||||
|
:
|
||||||
|
Filter(image, listener, what),
|
||||||
|
fOp(op),
|
||||||
|
fBPP(0),
|
||||||
|
fWidth(0),
|
||||||
|
fHeight(0),
|
||||||
|
fSrcBPR(0),
|
||||||
|
fDestBPR(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
ImageProcessor::CreateDestImage(BBitmap* /* srcImage */)
|
ImageProcessor::CreateDestImage(BBitmap* /* srcImage */)
|
||||||
{
|
{
|
||||||
@@ -936,20 +980,21 @@ ImageProcessor::CreateDestImage(BBitmap* /* srcImage */)
|
|||||||
BBitmap* bm;
|
BBitmap* bm;
|
||||||
BRect rect;
|
BRect rect;
|
||||||
|
|
||||||
if (GetSrcImage() == NULL) return NULL;
|
if (GetSrcImage() == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
cs = GetSrcImage()->ColorSpace();
|
cs = GetSrcImage()->ColorSpace();
|
||||||
fBPP = BytesPerPixel(cs);
|
fBPP = BytesPerPixel(cs);
|
||||||
if (fBPP < 1) return NULL;
|
if (fBPP < 1)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
fWidth = GetSrcImage()->Bounds().IntegerWidth();
|
fWidth = GetSrcImage()->Bounds().IntegerWidth();
|
||||||
fHeight = GetSrcImage()->Bounds().IntegerHeight();
|
fHeight = GetSrcImage()->Bounds().IntegerHeight();
|
||||||
|
|
||||||
if (fOp == kRotateClockwise || fOp == kRotateCounterClockwise) {
|
if (fOp == kRotateClockwise || fOp == kRotateCounterClockwise)
|
||||||
rect.Set(0, 0, fHeight, fWidth);
|
rect.Set(0, 0, fHeight, fWidth);
|
||||||
} else {
|
else
|
||||||
rect.Set(0, 0, fWidth, fHeight);
|
rect.Set(0, 0, fWidth, fHeight);
|
||||||
}
|
|
||||||
|
|
||||||
bm = new BBitmap(rect, cs);
|
bm = new BBitmap(rect, cs);
|
||||||
if (!IsBitmapValid(bm)) {
|
if (!IsBitmapValid(bm)) {
|
||||||
@@ -963,12 +1008,14 @@ ImageProcessor::CreateDestImage(BBitmap* /* srcImage */)
|
|||||||
return bm;
|
return bm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
ImageProcessor::GetNumberOfUnits()
|
ImageProcessor::GetNumberOfUnits()
|
||||||
{
|
{
|
||||||
return GetSrcImage()->Bounds().IntegerHeight() + 1;
|
return GetSrcImage()->Bounds().IntegerHeight() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
ImageProcessor::BytesPerPixel(color_space cs) const
|
ImageProcessor::BytesPerPixel(color_space cs) const
|
||||||
{
|
{
|
||||||
@@ -995,11 +1042,14 @@ ImageProcessor::BytesPerPixel(color_space cs) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ImageProcessor::CopyPixel(uchar* dest, int32 destX, int32 destY, const uchar* src, int32 x, int32 y)
|
ImageProcessor::CopyPixel(uchar* dest, int32 destX, int32 destY,
|
||||||
|
const uchar* src, int32 x, int32 y)
|
||||||
{
|
{
|
||||||
// Note: On my systems (Dual Intel P3 866MHz and AMD Athlon 1GHz), replacing
|
// Note: On my systems (Dual Intel P3 866MHz and AMD Athlon 1GHz),
|
||||||
// the multiplications below with pointer arithmethics showed no speedup at all!
|
// replacing the multiplications below with pointer arithmethics showed
|
||||||
|
// no speedup at all!
|
||||||
dest += fDestBPR * destY + destX * fBPP;
|
dest += fDestBPR * destY + destX * fBPP;
|
||||||
src += fSrcBPR * y + x * fBPP;
|
src += fSrcBPR * y + x * fBPP;
|
||||||
// Replacing memcpy with this switch statement is slightly faster
|
// Replacing memcpy with this switch statement is slightly faster
|
||||||
@@ -1016,6 +1066,7 @@ ImageProcessor::CopyPixel(uchar* dest, int32 destX, int32 destY, const uchar* sr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Note: For B_CMAP8 InvertPixel inverts the color index not the color value!
|
// Note: For B_CMAP8 InvertPixel inverts the color index not the color value!
|
||||||
void
|
void
|
||||||
ImageProcessor::InvertPixel(int32 x, int32 y, uchar* dest, const uchar* src)
|
ImageProcessor::InvertPixel(int32 x, int32 y, uchar* dest, const uchar* src)
|
||||||
@@ -1035,18 +1086,19 @@ ImageProcessor::InvertPixel(int32 x, int32 y, uchar* dest, const uchar* src)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: On my systems, the operation kInvert shows a speedup on multiple CPUs only!
|
|
||||||
|
// Note: On my systems, the operation kInvert shows a speedup on
|
||||||
|
// multiple CPUs only!
|
||||||
void
|
void
|
||||||
ImageProcessor::Run(int32 i, int32 n)
|
ImageProcessor::Run(int32 i, int32 n)
|
||||||
{
|
{
|
||||||
int32 from, to;
|
int32 from, to;
|
||||||
int32 height = (fHeight + 1) / n;
|
int32 height = (fHeight + 1) / n;
|
||||||
from = i * height;
|
from = i * height;
|
||||||
if (i+1 == n) {
|
if (i + 1 == n)
|
||||||
to = fHeight;
|
to = fHeight;
|
||||||
} else {
|
else
|
||||||
to = from + height - 1;
|
to = from + height - 1;
|
||||||
}
|
|
||||||
|
|
||||||
int32 x, y, destX, destY;
|
int32 x, y, destX, destY;
|
||||||
const uchar* src = (uchar*)GetSrcImage()->Bits();
|
const uchar* src = (uchar*)GetSrcImage()->Bits();
|
||||||
@@ -1097,5 +1149,4 @@ ImageProcessor::Run(int32 i, int32 n)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ const int32 kFPOne = to_fixed_point(1);
|
|||||||
// Used by class Filter
|
// Used by class Filter
|
||||||
class FilterThread {
|
class FilterThread {
|
||||||
public:
|
public:
|
||||||
FilterThread(Filter* filter, int32 i, int32 n, bool runInCurrentThread = false);
|
FilterThread(Filter* filter, int32 i, int32 n,
|
||||||
|
bool runInCurrentThread = false);
|
||||||
~FilterThread();
|
~FilterThread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -161,7 +162,8 @@ private:
|
|||||||
// Scales and optionally dithers an image
|
// Scales and optionally dithers an image
|
||||||
class Scaler : public Filter {
|
class Scaler : public Filter {
|
||||||
public:
|
public:
|
||||||
Scaler(BBitmap* image, BRect rect, BMessenger listener, uint32 what, bool dither);
|
Scaler(BBitmap* image, BRect rect, BMessenger listener, uint32 what,
|
||||||
|
bool dither);
|
||||||
~Scaler();
|
~Scaler();
|
||||||
|
|
||||||
BBitmap* CreateDestImage(BBitmap* srcImage);
|
BBitmap* CreateDestImage(BBitmap* srcImage);
|
||||||
@@ -173,7 +175,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
void ScaleBilinear(int32 fromRow, int32 toRow);
|
void ScaleBilinear(int32 fromRow, int32 toRow);
|
||||||
void ScaleBilinearFP(int32 fromRow, int32 toRow);
|
void ScaleBilinearFP(int32 fromRow, int32 toRow);
|
||||||
inline void RowValues(float* sum, const uchar* srcData, intType srcW, intType fromX, intType toX, const float a0X, const float a1X, const int32 kBPP);
|
inline void RowValues(float* sum, const uchar* srcData, intType srcW,
|
||||||
|
intType fromX, intType toX, const float a0X,
|
||||||
|
const float a1X, const int32 kBPP);
|
||||||
void DownScaleBilinear(int32 fromRow, int32 toRow);
|
void DownScaleBilinear(int32 fromRow, int32 toRow);
|
||||||
static inline uchar Limit(intType value);
|
static inline uchar Limit(intType value);
|
||||||
void Dither(int32 fromRow, int32 toRow);
|
void Dither(int32 fromRow, int32 toRow);
|
||||||
@@ -195,14 +199,16 @@ public:
|
|||||||
kNumberOfAffineTransformations = 4
|
kNumberOfAffineTransformations = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
ImageProcessor(enum operation op, BBitmap* image, BMessenger listener, uint32 what);
|
ImageProcessor(enum operation op, BBitmap* image, BMessenger listener,
|
||||||
|
uint32 what);
|
||||||
BBitmap* CreateDestImage(BBitmap* srcImage);
|
BBitmap* CreateDestImage(BBitmap* srcImage);
|
||||||
int32 GetNumberOfUnits();
|
int32 GetNumberOfUnits();
|
||||||
void Run(int32 i, int32 n);
|
void Run(int32 i, int32 n);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32 BytesPerPixel(color_space cs) const;
|
int32 BytesPerPixel(color_space cs) const;
|
||||||
inline void CopyPixel(uchar* dest, int32 destX, int32 destY, const uchar* src, int32 x, int32 y);
|
inline void CopyPixel(uchar* dest, int32 destX, int32 destY,
|
||||||
|
const uchar* src, int32 x, int32 y);
|
||||||
inline void InvertPixel(int32 x, int32 y, uchar* dest, const uchar* src);
|
inline void InvertPixel(int32 x, int32 y, uchar* dest, const uchar* src);
|
||||||
|
|
||||||
enum operation fOp;
|
enum operation fOp;
|
||||||
|
|||||||
@@ -374,14 +374,16 @@ AutoAdjustingNavigator::~AutoAdjustingNavigator()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AutoAdjustingNavigator::FindNextImage(const entry_ref& currentRef, entry_ref& nextRef,
|
AutoAdjustingNavigator::FindNextImage(const entry_ref& currentRef,
|
||||||
bool next, bool rewind)
|
entry_ref& nextRef, bool next, bool rewind)
|
||||||
{
|
{
|
||||||
if (_CheckForTracker(currentRef))
|
if (_CheckForTracker(currentRef))
|
||||||
return fTrackerNavigator->FindNextImage(currentRef, nextRef, next, rewind);
|
return fTrackerNavigator->FindNextImage(currentRef, nextRef, next,
|
||||||
|
rewind);
|
||||||
|
|
||||||
if (fFolderNavigator != NULL)
|
if (fFolderNavigator != NULL)
|
||||||
return fFolderNavigator->FindNextImage(currentRef, nextRef, next, rewind);
|
return fFolderNavigator->FindNextImage(currentRef, nextRef, next,
|
||||||
|
rewind);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <GroupLayoutBuilder.h>
|
|
||||||
#include <GridLayoutBuilder.h>
|
#include <GridLayoutBuilder.h>
|
||||||
#include <Locale.h>
|
#include <GroupLayoutBuilder.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
|
#include <Locale.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include "ShowImageConstants.h"
|
#include "ShowImageConstants.h"
|
||||||
|
|||||||
@@ -129,19 +129,18 @@ compose_checker_background(const BBitmap* bitmap)
|
|||||||
p[3] = 255;
|
p[3] = 255;
|
||||||
alpha = 255 - alpha;
|
alpha = 255 - alpha;
|
||||||
if (x % 10 >= 5) {
|
if (x % 10 >= 5) {
|
||||||
if (i % 10 >= 5) {
|
if (i % 10 >= 5)
|
||||||
blend_colors(p, kAlphaLow.red, kAlphaLow.green, kAlphaLow.blue, alpha);
|
blend_colors(p, kAlphaLow.red, kAlphaLow.green, kAlphaLow.blue, alpha);
|
||||||
} else {
|
else
|
||||||
blend_colors(p, kAlphaHigh.red, kAlphaHigh.green, kAlphaHigh.blue, alpha);
|
blend_colors(p, kAlphaHigh.red, kAlphaHigh.green, kAlphaHigh.blue, alpha);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (i % 10 >= 5) {
|
if (i % 10 >= 5)
|
||||||
blend_colors(p, kAlphaHigh.red, kAlphaHigh.green, kAlphaHigh.blue, alpha);
|
blend_colors(p, kAlphaHigh.red, kAlphaHigh.green, kAlphaHigh.blue, alpha);
|
||||||
} else {
|
else
|
||||||
blend_colors(p, kAlphaLow.red, kAlphaLow.green, kAlphaLow.blue, alpha);
|
blend_colors(p, kAlphaLow.red, kAlphaLow.green, kAlphaLow.blue, alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
p += 4;
|
p += 4;
|
||||||
}
|
}
|
||||||
bits += bpr;
|
bits += bpr;
|
||||||
@@ -249,9 +248,8 @@ ShowImageView::Pulse()
|
|||||||
BPoint mousePos;
|
BPoint mousePos;
|
||||||
uint32 buttons;
|
uint32 buttons;
|
||||||
GetMouse(&mousePos, &buttons, false);
|
GetMouse(&mousePos, &buttons, false);
|
||||||
if (Bounds().Contains(mousePos)) {
|
if (Bounds().Contains(mousePos))
|
||||||
be_app->ObscureCursor();
|
be_app->ObscureCursor();
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
fHideCursorCountDown--;
|
fHideCursorCountDown--;
|
||||||
}
|
}
|
||||||
@@ -812,9 +810,9 @@ ShowImageView::_AddSupportedTypes(BMessage* msg, BBitmap* bitmap)
|
|||||||
int32 count;
|
int32 count;
|
||||||
roster->GetOutputFormats(info[i].translator, &formats, &count);
|
roster->GetOutputFormats(info[i].translator, &formats, &count);
|
||||||
for (int32 j = 0; j < count; j++) {
|
for (int32 j = 0; j < count; j++) {
|
||||||
if (fMimeType == formats[j].MIME) {
|
if (fMimeType == formats[j].MIME)
|
||||||
foundCurrent = true;
|
foundCurrent = true;
|
||||||
} else if (strcmp(formats[j].MIME, "image/x-be-bitmap") != 0) {
|
else if (strcmp(formats[j].MIME, "image/x-be-bitmap") != 0) {
|
||||||
foundOther = true;
|
foundOther = true;
|
||||||
// needed to send data in message
|
// needed to send data in message
|
||||||
msg->AddString("be:types", formats[j].MIME);
|
msg->AddString("be:types", formats[j].MIME);
|
||||||
@@ -965,14 +963,16 @@ ShowImageView::SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::_SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format* format)
|
ShowImageView::_SendInMessage(BMessage* msg, BBitmap* bitmap,
|
||||||
|
translation_format* format)
|
||||||
{
|
{
|
||||||
BMessage reply(B_MIME_DATA);
|
BMessage reply(B_MIME_DATA);
|
||||||
BBitmapStream stream(bitmap); // destructor deletes bitmap
|
BBitmapStream stream(bitmap); // destructor deletes bitmap
|
||||||
BTranslatorRoster* roster = BTranslatorRoster::Default();
|
BTranslatorRoster* roster = BTranslatorRoster::Default();
|
||||||
BMallocIO memStream;
|
BMallocIO memStream;
|
||||||
if (roster->Translate(&stream, NULL, NULL, &memStream, format->type) == B_OK) {
|
if (roster->Translate(&stream, NULL, NULL, &memStream, format->type) == B_OK) {
|
||||||
reply.AddData(format->MIME, B_MIME_TYPE, memStream.Buffer(), memStream.BufferLength());
|
reply.AddData(format->MIME, B_MIME_TYPE, memStream.Buffer(),
|
||||||
|
memStream.BufferLength());
|
||||||
msg->SendReply(&reply);
|
msg->SendReply(&reply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1435,13 +1435,13 @@ ShowImageView::FixupScrollBar(orientation o, float bitmapLength,
|
|||||||
psb = ScrollBar(o);
|
psb = ScrollBar(o);
|
||||||
if (psb) {
|
if (psb) {
|
||||||
range = bitmapLength - viewLength;
|
range = bitmapLength - viewLength;
|
||||||
if (range < 0.0) {
|
if (range < 0.0)
|
||||||
range = 0.0;
|
range = 0.0;
|
||||||
}
|
|
||||||
prop = viewLength / bitmapLength;
|
prop = viewLength / bitmapLength;
|
||||||
if (prop > 1.0) {
|
if (prop > 1.0)
|
||||||
prop = 1.0;
|
prop = 1.0;
|
||||||
}
|
|
||||||
psb->SetRange(0, range);
|
psb->SetRange(0, range);
|
||||||
psb->SetProportion(prop);
|
psb->SetProportion(prop);
|
||||||
psb->SetSteps(10, 100);
|
psb->SetSteps(10, 100);
|
||||||
@@ -1496,7 +1496,8 @@ ShowImageView::Undo()
|
|||||||
BBitmap* undoSelection;
|
BBitmap* undoSelection;
|
||||||
undoSelection = fUndo.GetSelectionBitmap();
|
undoSelection = fUndo.GetSelectionBitmap();
|
||||||
// NOTE: ShowImageView is responsible for deleting this bitmap
|
// NOTE: ShowImageView is responsible for deleting this bitmap
|
||||||
// (Which it will, as it would with a fSelectionBitmap that it allocated itself)
|
// (Which it will, as it would with a fSelectionBitmap that it
|
||||||
|
// allocated itself)
|
||||||
if (!undoSelection)
|
if (!undoSelection)
|
||||||
_SetHasSelection(false);
|
_SetHasSelection(false);
|
||||||
else {
|
else {
|
||||||
@@ -1683,10 +1684,14 @@ ShowImageView::_DoImageOperation(ImageProcessor::operation op, bool quiet)
|
|||||||
// update orientation state
|
// update orientation state
|
||||||
if (op != ImageProcessor::kInvert) {
|
if (op != ImageProcessor::kInvert) {
|
||||||
// Note: If one of these fails, check its definition in class ImageProcessor.
|
// Note: If one of these fails, check its definition in class ImageProcessor.
|
||||||
// ASSERT(ImageProcessor::kRotateClockwise < ImageProcessor::kNumberOfAffineTransformations);
|
// ASSERT(ImageProcessor::kRotateClockwise <
|
||||||
// ASSERT(ImageProcessor::kRotateCounterClockwise < ImageProcessor::kNumberOfAffineTransformations);
|
// ImageProcessor::kNumberOfAffineTransformations);
|
||||||
// ASSERT(ImageProcessor::kFlipLeftToRight < ImageProcessor::kNumberOfAffineTransformations);
|
// ASSERT(ImageProcessor::kRotateCounterClockwise <
|
||||||
// ASSERT(ImageProcessor::kFlipTopToBottom < ImageProcessor::kNumberOfAffineTransformations);
|
// ImageProcessor::kNumberOfAffineTransformations);
|
||||||
|
// ASSERT(ImageProcessor::kFlipLeftToRight <
|
||||||
|
// ImageProcessor::kNumberOfAffineTransformations);
|
||||||
|
// ASSERT(ImageProcessor::kFlipTopToBottom <
|
||||||
|
// ImageProcessor::kNumberOfAffineTransformations);
|
||||||
fImageOrientation = fTransformation[op][fImageOrientation];
|
fImageOrientation = fTransformation[op][fImageOrientation];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1697,10 +1702,9 @@ ShowImageView::_DoImageOperation(ImageProcessor::operation op, bool quiet)
|
|||||||
if (orientation != k0) {
|
if (orientation != k0) {
|
||||||
node.WriteAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE, B_INT32_TYPE, 0,
|
node.WriteAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE, B_INT32_TYPE, 0,
|
||||||
&orientation, sizeof(orientation));
|
&orientation, sizeof(orientation));
|
||||||
} else {
|
} else
|
||||||
node.RemoveAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE);
|
node.RemoveAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// set new bitmap
|
// set new bitmap
|
||||||
_DeleteBitmap();
|
_DeleteBitmap();
|
||||||
|
|||||||
@@ -990,7 +990,8 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
backgroundsMessage.AddRef("refs", fImageView->Image());
|
backgroundsMessage.AddRef("refs", fImageView->Image());
|
||||||
// This is used in the Backgrounds code for scaled placement
|
// This is used in the Backgrounds code for scaled placement
|
||||||
backgroundsMessage.AddInt32("placement", 'scpl');
|
backgroundsMessage.AddInt32("placement", 'scpl');
|
||||||
be_roster->Launch("application/x-vnd.haiku-backgrounds", &backgroundsMessage);
|
be_roster->Launch("application/x-vnd.haiku-backgrounds",
|
||||||
|
&backgroundsMessage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1050,9 +1051,9 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
if (message->FindFloat("offset", &offset) == B_OK
|
if (message->FindFloat("offset", &offset) == B_OK
|
||||||
&& message->FindBool("show", &show) == B_OK) {
|
&& message->FindBool("show", &show) == B_OK) {
|
||||||
// Compensate rounding errors with the final placement
|
// Compensate rounding errors with the final placement
|
||||||
if (show) {
|
if (show)
|
||||||
fToolBarView->MoveTo(fToolBarView->Frame().left, 0);
|
fToolBarView->MoveTo(fToolBarView->Frame().left, 0);
|
||||||
} else {
|
else {
|
||||||
fToolBarView->MoveTo(fToolBarView->Frame().left, offset);
|
fToolBarView->MoveTo(fToolBarView->Frame().left, offset);
|
||||||
fToolBarView->Hide();
|
fToolBarView->Hide();
|
||||||
}
|
}
|
||||||
@@ -1174,7 +1175,8 @@ ShowImageWindow::_SaveToFile(BMessage* message)
|
|||||||
|
|
||||||
int32 i;
|
int32 i;
|
||||||
for (i = 0; i < outCount; i++) {
|
for (i = 0; i < outCount; i++) {
|
||||||
if (outFormat[i].group == B_TRANSLATOR_BITMAP && outFormat[i].type == outType)
|
if (outFormat[i].group == B_TRANSLATOR_BITMAP && outFormat[i].type
|
||||||
|
== outType)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == outCount)
|
if (i == outCount)
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ ToolBarView::AddAction(uint32 command, BHandler* target, const BBitmap* icon,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ToolBarView::AddAction(BMessage* message, BHandler* target, const BBitmap* icon,
|
ToolBarView::AddAction(BMessage* message, BHandler* target,
|
||||||
const char* toolTipText)
|
const BBitmap* icon, const char* toolTipText)
|
||||||
{
|
{
|
||||||
BIconButton* button = new BIconButton(NULL, NULL, message, target);
|
BIconButton* button = new BIconButton(NULL, NULL, message, target);
|
||||||
button->SetIcon(icon);
|
button->SetIcon(icon);
|
||||||
|
|||||||
Reference in New Issue
Block a user