From 537a273cced14e2da799ae1e4c3474a9fd74d663 Mon Sep 17 00:00:00 2001 From: Humdinger Date: Sun, 24 Jun 2012 19:45:33 +0200 Subject: [PATCH] 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. --- src/apps/showimage/Filter.cpp | 309 +++++++++++++--------- src/apps/showimage/Filter.h | 46 ++-- src/apps/showimage/ImageFileNavigator.cpp | 10 +- src/apps/showimage/PrintOptionsWindow.cpp | 6 +- src/apps/showimage/ProgressWindow.cpp | 6 +- src/apps/showimage/SelectionBox.cpp | 6 +- src/apps/showimage/ShowImageApp.cpp | 2 +- src/apps/showimage/ShowImageUndo.cpp | 4 +- src/apps/showimage/ShowImageView.cpp | 122 ++++----- src/apps/showimage/ShowImageView.h | 18 +- src/apps/showimage/ShowImageWindow.cpp | 16 +- src/apps/showimage/ToolBarView.cpp | 4 +- 12 files changed, 307 insertions(+), 242 deletions(-) diff --git a/src/apps/showimage/Filter.cpp b/src/apps/showimage/Filter.cpp index 17678b53db..b6a8702471 100644 --- a/src/apps/showimage/Filter.cpp +++ b/src/apps/showimage/Filter.cpp @@ -1,6 +1,6 @@ /* - * Copyright 2003-2006, Haiku. - * Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd. + * Copyright 2003-2006, Haiku, Inc. All rights reserved. + * Copyright 2004-2005 yellowTAB GmbH. All Rights Reserved. * Copyright 2006 Bernd Korz. All Rights Reserved * Distributed under the terms of the MIT License. * @@ -21,29 +21,32 @@ // Implementation of FilterThread -FilterThread::FilterThread(Filter* filter, int32 i, int32 n, bool runInCurrentThread) - : fFilter(filter) - , fI(i) - , fN(n) +FilterThread::FilterThread(Filter* filter, int32 i, int32 n, + bool runInCurrentThread) + : fFilter(filter), + fI(i), + fN(n) { - if (runInCurrentThread) { + if (runInCurrentThread) Run(); - } else { + else { thread_id tid; - tid = spawn_thread(worker_thread, "filter", suggest_thread_priority(B_STATUS_RENDERING), this); - if (tid >= 0) { + tid = spawn_thread(worker_thread, "filter", + suggest_thread_priority(B_STATUS_RENDERING), this); + if (tid >= 0) resume_thread(tid); - } else { + else delete this; - } } } + FilterThread::~FilterThread() { fFilter->FilterThreadDone(); } + status_t FilterThread::worker_thread(void* data) { @@ -51,6 +54,7 @@ FilterThread::worker_thread(void* data) return thread->Run(); } + status_t FilterThread::Run() { @@ -67,24 +71,25 @@ FilterThread::Run() new FilterThread(fFilter, i, fN); } } - if (fFilter->GetBitmap()) { + if (fFilter->GetBitmap()) fFilter->Run(fI, fN); - } + delete this; return B_OK; } // Implementation of Filter Filter::Filter(BBitmap* image, BMessenger listener, uint32 what) - : fListener(listener) - , fWhat(what) - , fStarted(false) - , fN(0) - , fNumberOfThreads(0) - , fIsRunning(false) - , fSrcImage(image) - , fDestImageInitialized(false) - , fDestImage(NULL) + : + fListener(listener), + fWhat(what), + fStarted(false), + fN(0), + fNumberOfThreads(0), + fIsRunning(false), + fSrcImage(image), + fDestImageInitialized(false), + fDestImage(NULL) { fCPUCount = NumberOfActiveCPUs(); @@ -95,12 +100,14 @@ Filter::Filter(BBitmap* image, BMessenger listener, uint32 what) #endif } + Filter::~Filter() { delete fDestImage; delete_sem(fWaitForThreads); } + BBitmap* Filter::GetBitmap() { @@ -111,6 +118,7 @@ Filter::GetBitmap() return fDestImage; } + BBitmap* Filter::DetachBitmap() { @@ -119,6 +127,7 @@ Filter::DetachBitmap() return image; } + void Filter::Start(bool async) { @@ -136,11 +145,11 @@ Filter::Start(bool async) // start first filter thread new FilterThread(this, 0, fN, !async); - if (!async) { + if (!async) Wait(); - } } + void Filter::Wait() { @@ -152,6 +161,7 @@ Filter::Wait() } } + void Filter::Stop() { @@ -160,17 +170,20 @@ Filter::Stop() Wait(); } + bool Filter::IsRunning() const { return fIsRunning; } + void Filter::Completed() { } + void Filter::FilterThreadDone() { @@ -179,14 +192,15 @@ Filter::FilterThreadDone() delete fStopWatch; fStopWatch = NULL; #endif Completed(); - if (fIsRunning) { + if (fIsRunning) fListener.SendMessage(fWhat); - } + fIsRunning = false; } release_sem(fWaitForThreads); } + void Filter::FilterThreadInitFailed() { @@ -197,38 +211,43 @@ Filter::FilterThreadInitFailed() release_sem_etc(fWaitForThreads, fN, 0); } + bool Filter::IsBitmapValid(BBitmap* bitmap) const { return bitmap != NULL && bitmap->InitCheck() == B_OK && bitmap->IsValid(); } + int32 Filter::NumberOfThreads() { const int32 units = GetNumberOfUnits(); int32 n; n = units / 32; // at least 32 units per CPU - if (n > CPUCount()) { + if (n > CPUCount()) n = CPUCount(); - } else if (n <= 0) { + else if (n <= 0) n = 1; // at least one thread! - } + return n; } + BBitmap* Filter::GetSrcImage() { return fSrcImage; } + BBitmap* Filter::GetDestImage() { return fDestImage; } + int32 Filter::NumberOfActiveCPUs() const { @@ -247,15 +266,19 @@ Filter::NumberOfActiveCPUs() const return cpuCount; } + // Implementation of (bilinear) Scaler -Scaler::Scaler(BBitmap* image, BRect rect, BMessenger listener, uint32 what, bool dither) - : Filter(image, listener, what) - , fScaledImage(NULL) - , fRect(rect) - , fDither(dither) +Scaler::Scaler(BBitmap* image, BRect rect, BMessenger listener, uint32 what, + bool dither) + : + Filter(image, listener, what), + fScaledImage(NULL), + fRect(rect), + fDither(dither) { } + Scaler::~Scaler() { if (GetDestImage() != fScaledImage) { @@ -264,13 +287,17 @@ Scaler::~Scaler() } } + BBitmap* 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()); - BBitmap* destImage = new BBitmap(dest, fDither ? B_CMAP8 : srcImage->ColorSpace()); + BBitmap* destImage = new BBitmap(dest, + fDither ? B_CMAP8 : srcImage->ColorSpace()); if (!IsBitmapValid(destImage)) { delete destImage; @@ -287,19 +314,19 @@ Scaler::CreateDestImage(BBitmap* srcImage) fScaledImage = NULL; return NULL; } - } else { + } else fScaledImage = destImage; - } return destImage; } + bool Scaler::Matches(BRect rect, bool dither) const { - return fRect.IntegerWidth() == rect.IntegerWidth() && - fRect.IntegerHeight() == rect.IntegerHeight() && - fDither == dither; + return fRect.IntegerWidth() == rect.IntegerWidth() + && fRect.IntegerHeight() == rect.IntegerHeight() + && fDither == dither; } @@ -310,6 +337,7 @@ typedef struct { float alpha1; } ColumnData; + void Scaler::ScaleBilinear(intType fromRow, int32 toRow) { @@ -343,7 +371,7 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow) columnData = new ColumnData[destW]; cd = columnData; - for (i = 0; i < destW; i ++, cd++) { + for (i = 0; i < destW; i++, cd++) { float column = (float)i * (float)srcW / (float)destW; cd->srcColumn = (intType)column; cd->alpha1 = column - cd->srcColumn; @@ -352,16 +380,16 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow) destDataRow = destBits + fromRow * destBPR; - for (y = fromRow; IsRunning() && y <= toRow; y ++, destDataRow += destBPR) { + for (y = fromRow; IsRunning() && y <= toRow; y++, destDataRow += destBPR) { float row; intType srcRow; float alpha0, alpha1; - if (destH == 0) { + if (destH == 0) row = 0; - } else { + else row = (float)y * (float)srcH / (float)destH; - } + srcRow = (intType)row; alpha1 = row - srcRow; alpha0 = 1.0 - alpha1; @@ -434,6 +462,7 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow) delete[] columnData; } + // Scale bilinear using fixed point calculations // Is already more than two times faster than floating point version // on AMD Athlon 1 GHz and Dual Intel Pentium III 866 MHz. @@ -444,6 +473,7 @@ typedef struct { fixed_point alpha1; } ColumnDataFP; + void Scaler::ScaleBilinearFP(intType fromRow, int32 toRow) { @@ -482,8 +512,9 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow) columnData = new ColumnDataFP[destW]; cd = columnData; - for (i = 0; i < destW; i ++, cd++) { - fixed_point column = to_fixed_point(i) * (long_fixed_point)fpSrcW / fpDestW; + for (i = 0; i < destW; i++, cd++) { + fixed_point column = to_fixed_point(i) * (long_fixed_point)fpSrcW + / fpDestW; cd->srcColumn = from_fixed_point(column); cd->alpha1 = tail_value(column); // weigth for left pixel value cd->alpha0 = kFPOne - cd->alpha1; // weigth for right pixel value @@ -491,18 +522,18 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow) destDataRow = destBits + fromRow * destBPR; - for (y = fromRow; IsRunning() && y <= toRow; y ++, destDataRow += destBPR) { + for (y = fromRow; IsRunning() && y <= toRow; y++, destDataRow += destBPR) { fixed_point row; intType srcRow; fixed_point alpha0, alpha1; - if (fpDestH == 0) { + if (fpDestH == 0) row = 0; - } else { + else row = to_fixed_point(y) * (long_fixed_point)fpSrcH / fpDestH; - } + 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 srcData = srcBits + srcRow * srcBPR; @@ -566,14 +597,15 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow) destData[2] = a[2]; destData[3] = a[3]; } - } delete[] columnData; } + 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[1] = a0X * src[1]; @@ -581,7 +613,7 @@ Scaler::RowValues(float* sum, const uchar* src, intType srcW, intType fromX, int src += kBPP; - for (int32 x = fromX+1; x < toX; x ++, src += kBPP) { + for (int32 x = fromX + 1; x < toX; x++, src += kBPP) { sum[0] += src[0]; sum[1] += src[1]; sum[2] += src[2]; @@ -594,6 +626,7 @@ Scaler::RowValues(float* sum, const uchar* src, intType srcW, intType fromX, int } } + typedef struct { int32 from; int32 to; @@ -601,6 +634,7 @@ typedef struct { float alpha1; } DownScaleColumnData; + void Scaler::DownScaleBilinear(intType fromRow, int32 toRow) { @@ -637,9 +671,9 @@ Scaler::DownScaleBilinear(intType fromRow, int32 toRow) const float deltaY = (srcH + 1.0) / (destH + 1.0); const float deltaXY = deltaX * deltaY; - columnData = new DownScaleColumnData[destW+1]; + columnData = new DownScaleColumnData[destW + 1]; DownScaleColumnData* cd = columnData; - for (x = 0; x <= destW; x ++, cd ++) { + for (x = 0; x <= destW; x++, cd++) { const float fFromX = x * deltaX; const float fToX = fFromX + deltaX; @@ -664,7 +698,7 @@ Scaler::DownScaleBilinear(intType fromRow, int32 toRow) destData = destDataRow; cd = columnData; - for (x = 0; x <= destW; x ++, destData += kBPP, cd ++) { + for (x = 0; x <= destW; x++, destData += kBPP, cd++) { const intType fromX = cd->from; const intType toX = cd->to; @@ -683,7 +717,7 @@ Scaler::DownScaleBilinear(intType fromRow, int32 toRow) srcData += srcBPR; - for (int32 r = fromY+1; r < toY; r ++, srcData += srcBPR) { + for (int32 r = fromY + 1; r < toY; r++, srcData += srcBPR) { RowValues(sum, srcData, srcW, fromX, toX, a0X, a1X, kBPP); totalSum[0] += sum[0]; totalSum[1] += sum[1]; @@ -706,6 +740,7 @@ Scaler::DownScaleBilinear(intType fromRow, int32 toRow) delete[] columnData; } + // Flyod-Steinberg Dithering // Filter (distribution of error to adjacent pixels, X is current pixel): // 0 X 7 @@ -715,6 +750,7 @@ typedef struct { intType error[3]; } DitheringColumnData; + uchar Scaler::Limit(intType value) { @@ -726,6 +762,7 @@ Scaler::Limit(intType value) return value; } + void Scaler::Dither(int32 fromRow, int32 toRow) { @@ -766,19 +803,20 @@ Scaler::Dither(int32 fromRow, int32 toRow) destBPR = dest->BytesPerRow(); // Allocate space for sentinel at left and right bounds, - // so that columnData[-1] and columnData[destW+1] can be safely accessed - columnData0 = new DitheringColumnData[destW+3]; + // so that columnData[-1] and columnData[destW + 1] can be safely accessed + columnData0 = new DitheringColumnData[destW + 3]; columnData = columnData0 + 1; // clear error cd = columnData; - for (x = destW; x >= 0; x --, cd ++) { - cd->error[0] = cd->error[1] = cd->error[2] =0; + for (x = destW; x >= 0; x --, cd++) { + cd->error[0] = cd->error[1] = cd->error[2] = 0; } srcDataRow = srcBits + fromRow * srcBPR; 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 error[0] = error[1] = error[2] = 0; srcData = srcDataRow; @@ -797,12 +835,12 @@ Scaler::Dither(int32 fromRow, int32 toRow) *destData = index; err[0] = color.red - actualColor.red; - err[1] = color.green -actualColor.green; - err[2] = color.blue -actualColor.blue; + err[1] = color.green - actualColor.green; + err[2] = color.blue - actualColor.blue; // distribute error // get error for next pixel - cd = &columnData[x+1]; + cd = &columnData[x + 1]; error[0] = cd->error[0] + 7 * err[0]; error[1] = cd->error[1] + 7 * err[1]; error[2] = cd->error[2] + 7 * err[2]; @@ -813,27 +851,27 @@ Scaler::Dither(int32 fromRow, int32 toRow) cd->error[2] = err[2]; // add error for pixel below current pixel - cd --; + cd--; cd->error[0] += 5 * err[0]; cd->error[1] += 5 * err[1]; cd->error[2] += 5 * err[2]; // add error for left pixel below current pixel - cd --; + cd--; cd->error[0] += 3 * err[0]; cd->error[1] += 3 * err[1]; cd->error[2] += 3 * err[2]; } // Note: Alogrithm has good results with "left to right" already // Optionally remove code to end of block: - y ++; + y++; srcDataRow += srcBPR; destDataRow += destBPR; if (y > toRow) break; // right to left error[0] = error[1] = error[2] = 0; srcData = srcDataRow + destW * kBPP; destData = destDataRow + destW; - for (x = 0; x <= destW; x ++, srcData -= kBPP, destData -= 1) { + for (x = 0; x <= destW; x++, srcData -= kBPP, destData -= 1) { rgb_color color, actualColor; uint8 index; @@ -847,12 +885,12 @@ Scaler::Dither(int32 fromRow, int32 toRow) *destData = index; err[0] = color.red - actualColor.red; - err[1] = color.green -actualColor.green; - err[2] = color.blue -actualColor.blue; + err[1] = color.green - actualColor.green; + err[2] = color.blue - actualColor.blue; // distribute error // get error for next pixel - cd = &columnData[x-1]; + cd = &columnData[x - 1]; error[0] = cd->error[0] + 7 * err[0]; error[1] = cd->error[1] + 7 * err[1]; error[2] = cd->error[2] + 7 * err[2]; @@ -863,13 +901,13 @@ Scaler::Dither(int32 fromRow, int32 toRow) cd->error[2] = err[2]; // add error for pixel below current pixel - cd ++; + cd++; cd->error[0] += 5 * err[0]; cd->error[1] += 5 * err[1]; cd->error[2] += 5 * err[2]; // add error for right pixel below current pixel - cd ++; + cd++; cd->error[0] += 3 * err[0]; cd->error[1] += 3 * err[1]; cd->error[2] += 3 * err[2]; @@ -879,12 +917,14 @@ Scaler::Dither(int32 fromRow, int32 toRow) delete[] columnData0; } + int32 Scaler::GetNumberOfUnits() { return fRect.IntegerHeight() + 1; } + void Scaler::Run(int32 i, int32 n) { @@ -892,43 +932,47 @@ Scaler::Run(int32 i, int32 n) imageHeight = GetDestImage()->Bounds().IntegerHeight() + 1; height = imageHeight / n; from = i * height; - if (i+1 == n) { + if (i + 1 == n) to = imageHeight - 1; - } else { + else to = from + height - 1; - } - if (GetDestImage()->Bounds().Width() >= GetSrcImage()->Bounds().Width()) { + + if (GetDestImage()->Bounds().Width() >= GetSrcImage()->Bounds().Width()) ScaleBilinearFP(from, to); - } else { + else DownScaleBilinear(from, to); - } - if (fDither) { + + if (fDither) Dither(from, to); - } + } + void Scaler::Completed() { - if (GetDestImage() != fScaledImage) { + if (GetDestImage() != fScaledImage) delete fScaledImage; - } + 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* ImageProcessor::CreateDestImage(BBitmap* /* srcImage */) { @@ -936,20 +980,21 @@ ImageProcessor::CreateDestImage(BBitmap* /* srcImage */) BBitmap* bm; BRect rect; - if (GetSrcImage() == NULL) return NULL; + if (GetSrcImage() == NULL) + return NULL; cs = GetSrcImage()->ColorSpace(); fBPP = BytesPerPixel(cs); - if (fBPP < 1) return NULL; + if (fBPP < 1) + return NULL; fWidth = GetSrcImage()->Bounds().IntegerWidth(); fHeight = GetSrcImage()->Bounds().IntegerHeight(); - if (fOp == kRotateClockwise || fOp == kRotateCounterClockwise) { + if (fOp == kRotateClockwise || fOp == kRotateCounterClockwise) rect.Set(0, 0, fHeight, fWidth); - } else { + else rect.Set(0, 0, fWidth, fHeight); - } bm = new BBitmap(rect, cs); if (!IsBitmapValid(bm)) { @@ -963,45 +1008,50 @@ ImageProcessor::CreateDestImage(BBitmap* /* srcImage */) return bm; } + int32 ImageProcessor::GetNumberOfUnits() { return GetSrcImage()->Bounds().IntegerHeight() + 1; } + int32 ImageProcessor::BytesPerPixel(color_space cs) const { switch (cs) { - case B_RGB32: // fall through - case B_RGB32_BIG: // fall through - case B_RGBA32: // fall through - case B_RGBA32_BIG: return 4; + case B_RGB32: // fall through + case B_RGB32_BIG: // fall through + case B_RGBA32: // fall through + case B_RGBA32_BIG: return 4; - case B_RGB24_BIG: // fall through - case B_RGB24: return 3; + case B_RGB24_BIG: // fall through + case B_RGB24: return 3; - case B_RGB16: // fall through - case B_RGB16_BIG: // fall through - case B_RGB15: // fall through - case B_RGB15_BIG: // fall through - case B_RGBA15: // fall through - case B_RGBA15_BIG: return 2; + case B_RGB16: // fall through + case B_RGB16_BIG: // fall through + case B_RGB15: // fall through + case B_RGB15_BIG: // fall through + case B_RGBA15: // fall through + case B_RGBA15_BIG: return 2; - case B_GRAY8: // fall through - case B_CMAP8: return 1; - case B_GRAY1: return 0; + case B_GRAY8: // fall through + case B_CMAP8: return 1; + case B_GRAY1: return 0; default: return -1; } } + 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 - // the multiplications below with pointer arithmethics showed no speedup at all! + // Note: On my systems (Dual Intel P3 866MHz and AMD Athlon 1GHz), + // replacing the multiplications below with pointer arithmethics showed + // no speedup at all! dest += fDestBPR * destY + destX * fBPP; - src += fSrcBPR * y + x *fBPP; + src += fSrcBPR * y + x * fBPP; // Replacing memcpy with this switch statement is slightly faster switch (fBPP) { case 4: @@ -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! void 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 ImageProcessor::Run(int32 i, int32 n) { int32 from, to; - int32 height = (fHeight+1) / n; + int32 height = (fHeight + 1) / n; from = i * height; - if (i+1 == n) { + if (i + 1 == n) to = fHeight; - } else { + else to = from + height - 1; - } int32 x, y, destX, destY; const uchar* src = (uchar*)GetSrcImage()->Bits(); @@ -1054,8 +1106,8 @@ ImageProcessor::Run(int32 i, int32 n) switch (fOp) { case kRotateClockwise: - for (y = from; y <= to; y ++) { - for (x = 0; x <= fWidth; x ++) { + for (y = from; y <= to; y++) { + for (x = 0; x <= fWidth; x++) { destX = fHeight - y; destY = x; CopyPixel(dest, destX, destY, src, x, y); @@ -1097,5 +1149,4 @@ ImageProcessor::Run(int32 i, int32 n) } break; } - } diff --git a/src/apps/showimage/Filter.h b/src/apps/showimage/Filter.h index 4419361df5..8021ca133f 100644 --- a/src/apps/showimage/Filter.h +++ b/src/apps/showimage/Filter.h @@ -63,16 +63,17 @@ const int32 kFPOne = to_fixed_point(1); // Used by class Filter class FilterThread { public: - FilterThread(Filter* filter, int32 i, int32 n, bool runInCurrentThread = false); + FilterThread(Filter* filter, int32 i, int32 n, + bool runInCurrentThread = false); ~FilterThread(); private: status_t Run(); static status_t worker_thread(void* data); - Filter* fFilter; - int32 fI; - int32 fN; + Filter* fFilter; + int32 fI; + int32 fN; }; class Filter { @@ -142,26 +143,27 @@ private: // Returns the number of active CPUs int32 CPUCount() const { return fCPUCount; } - BMessenger fListener; - uint32 fWhat; - int32 fCPUCount; // the number of active CPUs - bool fStarted; // has Start() been called? - sem_id fWaitForThreads; // to exit - int32 fN; // the number of used filter threads - volatile int32 fNumberOfThreads; // the current number of FilterThreads - volatile bool fIsRunning; // FilterThreads should process data as long as it is true - BBitmap* fSrcImage; - bool fDestImageInitialized; - BBitmap* fDestImage; + BMessenger fListener; + uint32 fWhat; + int32 fCPUCount; // the number of active CPUs + bool fStarted; // has Start() been called? + sem_id fWaitForThreads; // to exit + int32 fN; // the number of used filter threads + volatile int32 fNumberOfThreads; // the current number of FilterThreads + volatile bool fIsRunning; // FilterThreads should process data as long as it is true + BBitmap* fSrcImage; + bool fDestImageInitialized; + BBitmap* fDestImage; #if TIME_FILTER - BStopWatch* fStopWatch; + BStopWatch* fStopWatch; #endif }; // Scales and optionally dithers an image class Scaler : public Filter { public: - Scaler(BBitmap* image, BRect rect, BMessenger listener, uint32 what, bool dither); + Scaler(BBitmap* image, BRect rect, BMessenger listener, uint32 what, + bool dither); ~Scaler(); BBitmap* CreateDestImage(BBitmap* srcImage); @@ -173,7 +175,9 @@ public: private: void ScaleBilinear(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); static inline uchar Limit(intType value); void Dither(int32 fromRow, int32 toRow); @@ -195,14 +199,16 @@ public: 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); int32 GetNumberOfUnits(); void Run(int32 i, int32 n); private: 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); enum operation fOp; diff --git a/src/apps/showimage/ImageFileNavigator.cpp b/src/apps/showimage/ImageFileNavigator.cpp index b9ed68de4e..bf32b106c2 100644 --- a/src/apps/showimage/ImageFileNavigator.cpp +++ b/src/apps/showimage/ImageFileNavigator.cpp @@ -374,14 +374,16 @@ AutoAdjustingNavigator::~AutoAdjustingNavigator() bool -AutoAdjustingNavigator::FindNextImage(const entry_ref& currentRef, entry_ref& nextRef, - bool next, bool rewind) +AutoAdjustingNavigator::FindNextImage(const entry_ref& currentRef, + entry_ref& nextRef, bool next, bool rewind) { if (_CheckForTracker(currentRef)) - return fTrackerNavigator->FindNextImage(currentRef, nextRef, next, rewind); + return fTrackerNavigator->FindNextImage(currentRef, nextRef, next, + rewind); if (fFolderNavigator != NULL) - return fFolderNavigator->FindNextImage(currentRef, nextRef, next, rewind); + return fFolderNavigator->FindNextImage(currentRef, nextRef, next, + rewind); return false; } diff --git a/src/apps/showimage/PrintOptionsWindow.cpp b/src/apps/showimage/PrintOptionsWindow.cpp index fca276f913..782e43e70c 100644 --- a/src/apps/showimage/PrintOptionsWindow.cpp +++ b/src/apps/showimage/PrintOptionsWindow.cpp @@ -15,10 +15,10 @@ #include #include #include -#include #include -#include +#include #include +#include #include #include "ShowImageConstants.h" @@ -73,7 +73,7 @@ PrintOptions::SetWidth(float w) void PrintOptions::SetHeight(float h) { - fWidth = (fBounds.Width()+1) * h / (fBounds.Height()+1); + fWidth = (fBounds.Width() + 1) * h / (fBounds.Height() + 1); fHeight = h; } diff --git a/src/apps/showimage/ProgressWindow.cpp b/src/apps/showimage/ProgressWindow.cpp index 08221e5d91..70df9875f8 100644 --- a/src/apps/showimage/ProgressWindow.cpp +++ b/src/apps/showimage/ProgressWindow.cpp @@ -37,7 +37,7 @@ ProgressWindow::ProgressWindow() { BRect rect = Bounds(); - BView *view = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); + BView* view = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(view); @@ -106,7 +106,7 @@ ProgressWindow::Stop() void -ProgressWindow::MessageReceived(BMessage *message) +ProgressWindow::MessageReceived(BMessage* message) { switch (message->what) { case kMsgShow: @@ -123,7 +123,7 @@ ProgressWindow::MessageReceived(BMessage *message) if (message->FindFloat("percent", &percent) == B_OK) fStatusBar->Update(percent - fStatusBar->CurrentValue()); - const char *text; + const char* text; if (message->FindString("message", &text) == B_OK) fStatusBar->SetText(text); diff --git a/src/apps/showimage/SelectionBox.cpp b/src/apps/showimage/SelectionBox.cpp index 3fd92dbefb..08daf1701a 100644 --- a/src/apps/showimage/SelectionBox.cpp +++ b/src/apps/showimage/SelectionBox.cpp @@ -109,13 +109,13 @@ SelectionBox::Animate() { // rotate up uchar p = fPatternUp.data[0]; - for (int i = 0; i <= 6; i ++) + for (int i = 0; i <= 6; i++) fPatternUp.data[i] = fPatternUp.data[i + 1]; fPatternUp.data[7] = p; // rotate down p = fPatternDown.data[7]; - for (int i = 7; i >= 1; i --) + for (int i = 7; i >= 1; i--) fPatternDown.data[i] = fPatternDown.data[i - 1]; fPatternDown.data[0] = p; @@ -170,7 +170,7 @@ SelectionBox::_InitPatterns() uchar p; uchar p1 = 0x33; uchar p2 = 0xCC; - for (int i = 0; i <= 7; i ++) { + for (int i = 0; i <= 7; i++) { fPatternLeft.data[i] = p1; fPatternRight.data[i] = p2; if ((i / 2) % 2 == 0) diff --git a/src/apps/showimage/ShowImageApp.cpp b/src/apps/showimage/ShowImageApp.cpp index 00b45a1533..c3147da98e 100644 --- a/src/apps/showimage/ShowImageApp.cpp +++ b/src/apps/showimage/ShowImageApp.cpp @@ -207,7 +207,7 @@ void ShowImageApp::_BroadcastToWindows(BMessage* message) { const int32 count = CountWindows(); - for (int32 i = 0; i < count; i ++) { + for (int32 i = 0; i < count; i++) { // BMessenger checks for us if BWindow is still a valid object BMessenger messenger(WindowAt(i)); messenger.SendMessage(message); diff --git a/src/apps/showimage/ShowImageUndo.cpp b/src/apps/showimage/ShowImageUndo.cpp index 31a9073a68..d4c2ad7cf8 100644 --- a/src/apps/showimage/ShowImageUndo.cpp +++ b/src/apps/showimage/ShowImageUndo.cpp @@ -64,7 +64,7 @@ ShowImageUndo::SendUndoStateMessage(bool bCanUndo) void -ShowImageUndo::SetTo(BRect rect, BBitmap *restore, BBitmap *selection) +ShowImageUndo::SetTo(BRect rect, BBitmap* restore, BBitmap* selection) { // NOTE: THIS FUNCTION DOES NOT MAKE COPIES OF THE BITMAPS PASSED TO IT InternalClear(); @@ -79,7 +79,7 @@ ShowImageUndo::SetTo(BRect rect, BBitmap *restore, BBitmap *selection) void -ShowImageUndo::Undo(BRect rect, BBitmap *restore, BBitmap *selection) +ShowImageUndo::Undo(BRect rect, BBitmap* restore, BBitmap* selection) { // NOTE: THIS FUNCTION DOES NOT MAKE COPIES OF THE BITMAPS PASSED TO IT fUndoType = UNDO_REDO; diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index 22e14a4c52..86b3ee4c8a 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -90,8 +90,8 @@ ShowImageView::fTransformation[ImageProcessor::kNumberOfAffineTransformations] {k0V, k90V, k0H, k270V, k0, k90, k180, k270} }; -const rgb_color kAlphaLow = (rgb_color){ 0xbb, 0xbb, 0xbb, 0xff }; -const rgb_color kAlphaHigh = (rgb_color){ 0xe0, 0xe0, 0xe0, 0xff }; +const rgb_color kAlphaLow = (rgb_color) { 0xbb, 0xbb, 0xbb, 0xff }; +const rgb_color kAlphaHigh = (rgb_color) { 0xe0, 0xe0, 0xe0, 0xff }; const uint32 kMsgPopUpMenuClosed = 'pmcl'; @@ -129,17 +129,16 @@ compose_checker_background(const BBitmap* bitmap) p[3] = 255; alpha = 255 - alpha; if (x % 10 >= 5) { - if (i % 10 >= 5) { + if (i % 10 >= 5) blend_colors(p, kAlphaLow.red, kAlphaLow.green, kAlphaLow.blue, alpha); - } else { + else blend_colors(p, kAlphaHigh.red, kAlphaHigh.green, kAlphaHigh.blue, alpha); - } + } else { - if (i % 10 >= 5) { + if (i % 10 >= 5) blend_colors(p, kAlphaHigh.red, kAlphaHigh.green, kAlphaHigh.blue, alpha); - } else { + else blend_colors(p, kAlphaLow.red, kAlphaLow.green, kAlphaLow.blue, alpha); - } } } p += 4; @@ -171,7 +170,7 @@ PopUpMenu::~PopUpMenu() // #pragma mark - -ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode, +ShowImageView::ShowImageView(BRect rect, const char* name, uint32 resizingMode, uint32 flags) : BView(rect, name, resizingMode, flags), @@ -249,9 +248,8 @@ ShowImageView::Pulse() BPoint mousePos; uint32 buttons; GetMouse(&mousePos, &buttons, false); - if (Bounds().Contains(mousePos)) { + if (Bounds().Contains(mousePos)) be_app->ObscureCursor(); - } } else fHideCursorCountDown--; } @@ -263,7 +261,7 @@ ShowImageView::Pulse() void -ShowImageView::_SendMessageToWindow(BMessage *message) +ShowImageView::_SendMessageToWindow(BMessage* message) { BMessenger target(Window()); target.SendMessage(message); @@ -605,18 +603,18 @@ ShowImageView::_DrawBackground(BRect border) { BRect bounds(Bounds()); // top - FillRect(BRect(0, 0, bounds.right, border.top-1), B_SOLID_LOW); + FillRect(BRect(0, 0, bounds.right, border.top - 1), B_SOLID_LOW); // left - FillRect(BRect(0, border.top, border.left-1, border.bottom), B_SOLID_LOW); + FillRect(BRect(0, border.top, border.left - 1, border.bottom), B_SOLID_LOW); // right - FillRect(BRect(border.right+1, border.top, bounds.right, border.bottom), B_SOLID_LOW); + FillRect(BRect(border.right + 1, border.top, bounds.right, border.bottom), B_SOLID_LOW); // bottom - FillRect(BRect(0, border.bottom+1, bounds.right, bounds.bottom), B_SOLID_LOW); + FillRect(BRect(0, border.bottom + 1, bounds.right, bounds.bottom), B_SOLID_LOW); } void -ShowImageView::_LayoutCaption(BFont &font, BPoint &pos, BRect &rect) +ShowImageView::_LayoutCaption(BFont& font, BPoint& pos, BRect& rect) { font_height fontHeight; float width, height; @@ -790,7 +788,7 @@ ShowImageView::_CopySelection(uchar alpha, bool imageSize) bool ShowImageView::_AddSupportedTypes(BMessage* msg, BBitmap* bitmap) { - BTranslatorRoster *roster = BTranslatorRoster::Default(); + BTranslatorRoster* roster = BTranslatorRoster::Default(); if (roster == NULL) return false; @@ -812,9 +810,9 @@ ShowImageView::_AddSupportedTypes(BMessage* msg, BBitmap* bitmap) int32 count; roster->GetOutputFormats(info[i].translator, &formats, &count); for (int32 j = 0; j < count; j++) { - if (fMimeType == formats[j].MIME) { + if (fMimeType == formats[j].MIME) 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; // needed to send data in message msg->AddString("be:types", formats[j].MIME); @@ -932,7 +930,7 @@ ShowImageView::SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap, bool loop = true; while (loop) { - BTranslatorRoster *roster = BTranslatorRoster::Default(); + BTranslatorRoster* roster = BTranslatorRoster::Default(); if (!roster) break; // write data @@ -954,7 +952,7 @@ ShowImageView::SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap, char buffer[512]; snprintf(buffer, sizeof(buffer), B_TRANSLATE("The file '%s' could not " "be written."), name); - BAlert *palert = new BAlert("", buffer, B_TRANSLATE("OK")); + BAlert* palert = new BAlert("", buffer, B_TRANSLATE("OK")); palert->Go(); } @@ -965,14 +963,16 @@ ShowImageView::SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap, void -ShowImageView::_SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format* format) +ShowImageView::_SendInMessage(BMessage* msg, BBitmap* bitmap, + translation_format* format) { BMessage reply(B_MIME_DATA); BBitmapStream stream(bitmap); // destructor deletes bitmap - BTranslatorRoster *roster = BTranslatorRoster::Default(); + BTranslatorRoster* roster = BTranslatorRoster::Default(); BMallocIO memStream; 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); } } @@ -1335,7 +1335,7 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes) void -ShowImageView::_MouseWheelChanged(BMessage *msg) +ShowImageView::_MouseWheelChanged(BMessage* msg) { // The BeOS driver does not currently support // X wheel scrolling, therefore, dx is zero. @@ -1379,14 +1379,14 @@ void ShowImageView::_ShowPopUpMenu(BPoint screen) { if (!fShowingPopUpMenu) { - PopUpMenu* menu = new PopUpMenu("PopUpMenu", this); + PopUpMenu* menu = new PopUpMenu("PopUpMenu", this); - ShowImageWindow* window = dynamic_cast(Window()); - if (window != NULL) - window->BuildContextMenu(menu); + ShowImageWindow* window = dynamic_cast(Window()); + if (window != NULL) + window->BuildContextMenu(menu); - menu->Go(screen, true, true, true); - fShowingPopUpMenu = true; + menu->Go(screen, true, true, true); + fShowingPopUpMenu = true; } } @@ -1430,18 +1430,18 @@ ShowImageView::FixupScrollBar(orientation o, float bitmapLength, float viewLength) { float prop, range; - BScrollBar *psb; + BScrollBar* psb; psb = ScrollBar(o); if (psb) { range = bitmapLength - viewLength; - if (range < 0.0) { + if (range < 0.0) range = 0.0; - } + prop = viewLength / bitmapLength; - if (prop > 1.0) { + if (prop > 1.0) prop = 1.0; - } + psb->SetRange(0, range); psb->SetProportion(prop); psb->SetSteps(10, 100); @@ -1481,22 +1481,23 @@ ShowImageView::Undo() // backup current selection BRect undoneSelRect; - BBitmap *undoneSelection; + BBitmap* undoneSelection; undoneSelRect = fSelectionBox.Bounds(); undoneSelection = _CopySelection(); if (undoType == UNDO_UNDO) { - BBitmap *undoRestore; + BBitmap* undoRestore; undoRestore = fUndo.GetRestoreBitmap(); if (undoRestore) _MergeWithBitmap(undoRestore, fUndo.GetRect()); } // restore previous image/selection - BBitmap *undoSelection; + BBitmap* undoSelection; undoSelection = fUndo.GetSelectionBitmap(); // 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) _SetHasSelection(false); else { @@ -1683,10 +1684,14 @@ ShowImageView::_DoImageOperation(ImageProcessor::operation op, bool quiet) // update orientation state if (op != ImageProcessor::kInvert) { // Note: If one of these fails, check its definition in class ImageProcessor. -// ASSERT(ImageProcessor::kRotateClockwise < ImageProcessor::kNumberOfAffineTransformations); -// ASSERT(ImageProcessor::kRotateCounterClockwise < ImageProcessor::kNumberOfAffineTransformations); -// ASSERT(ImageProcessor::kFlipLeftToRight < ImageProcessor::kNumberOfAffineTransformations); -// ASSERT(ImageProcessor::kFlipTopToBottom < ImageProcessor::kNumberOfAffineTransformations); +// ASSERT(ImageProcessor::kRotateClockwise < +// ImageProcessor::kNumberOfAffineTransformations); +// ASSERT(ImageProcessor::kRotateCounterClockwise < +// ImageProcessor::kNumberOfAffineTransformations); +// ASSERT(ImageProcessor::kFlipLeftToRight < +// ImageProcessor::kNumberOfAffineTransformations); +// ASSERT(ImageProcessor::kFlipTopToBottom < +// ImageProcessor::kNumberOfAffineTransformations); fImageOrientation = fTransformation[op][fImageOrientation]; } @@ -1697,9 +1702,8 @@ ShowImageView::_DoImageOperation(ImageProcessor::operation op, bool quiet) if (orientation != k0) { node.WriteAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE, B_INT32_TYPE, 0, &orientation, sizeof(orientation)); - } else { + } else node.RemoveAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE); - } } // set new bitmap @@ -1749,7 +1753,7 @@ ShowImageView::ResizeImage(int w, int h) if (fBitmap == NULL || w < 1 || h < 1) return; - Scaler scaler(fBitmap, BRect(0, 0, w-1, h-1), BMessenger(), 0, false); + Scaler scaler(fBitmap, BRect(0, 0, w - 1, h - 1), BMessenger(), 0, false); scaler.Start(false); BBitmap* scaled = scaler.DetachBitmap(); if (scaled == NULL) { @@ -1784,17 +1788,17 @@ ShowImageView::_SetIcon(bool clear, icon_size which) BRect rect(fBitmap->Bounds()); float s; - s = size / (rect.Width()+1.0); + s = size / (rect.Width() + 1.0); - if (s * (rect.Height()+1.0) <= size) { - rect.right = size-1; - rect.bottom = static_cast(s * (rect.Height()+1.0))-1; + if (s * (rect.Height() + 1.0) <= size) { + rect.right = size - 1; + rect.bottom = static_cast(s * (rect.Height() + 1.0)) - 1; // center vertically rect.OffsetBy(0, (size - rect.IntegerHeight()) / 2); } else { - s = size / (rect.Height()+1.0); - rect.right = static_cast(s * (rect.Width()+1.0))-1; - rect.bottom = size-1; + s = size / (rect.Height() + 1.0); + rect.right = static_cast(s * (rect.Width() + 1.0)) - 1; + rect.bottom = size - 1; // center horizontally rect.OffsetBy((size - rect.IntegerWidth()) / 2, 0); } @@ -1806,7 +1810,7 @@ ShowImageView::_SetIcon(bool clear, icon_size which) scaler.Start(false); ASSERT(thumbnail->ColorSpace() == B_CMAP8); // create icon from thumbnail - BBitmap icon(BRect(0, 0, size-1, size-1), B_CMAP8); + BBitmap icon(BRect(0, 0, size - 1, size - 1), B_CMAP8); memset(icon.Bits(), B_TRANSPARENT_MAGIC_CMAP8, icon.BitsLength()); BScreen screen; const uchar* src = (uchar*)thumbnail->Bits(); @@ -1816,10 +1820,10 @@ ShowImageView::_SetIcon(bool clear, icon_size which) const int32 dx = (int32)rect.left; const int32 dy = (int32)rect.top; - for (int32 y = 0; y <= rect.IntegerHeight(); y ++) { - for (int32 x = 0; x <= rect.IntegerWidth(); x ++) { + for (int32 y = 0; y <= rect.IntegerHeight(); y++) { + for (int32 x = 0; x <= rect.IntegerWidth(); x++) { const uchar* s = src + y * srcBPR + x; - uchar* d = dest + (y+dy) * destBPR + (x+dx); + uchar* d = dest + (y + dy) * destBPR + (x + dx); *d = *s; } } diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h index b72be7d104..b14985b028 100644 --- a/src/apps/showimage/ShowImageView.h +++ b/src/apps/showimage/ShowImageView.h @@ -104,20 +104,20 @@ public: private: enum image_orientation { - k0, // 0 - k90, // 1 - k180, // 2 - k270, // 3 - k0V, // 4 - k90V, // 5 - k0H, // 6 - k270V, // 7 + k0, // 0 + k90, // 1 + k180, // 2 + k270, // 3 + k0V, // 4 + k90V, // 5 + k0H, // 6 + k270V, // 7 kNumberOfOrientations, }; void _SetHasSelection(bool bHasSelection); void _AnimateSelection(bool a); - void _SendMessageToWindow(BMessage *message); + void _SendMessageToWindow(BMessage* message); void _SendMessageToWindow(uint32 code); void _Notify(); void _UpdateStatusText(); diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index 1fad14f560..c6cabd2253 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -990,7 +990,8 @@ ShowImageWindow::MessageReceived(BMessage* message) backgroundsMessage.AddRef("refs", fImageView->Image()); // This is used in the Backgrounds code for scaled placement backgroundsMessage.AddInt32("placement", 'scpl'); - be_roster->Launch("application/x-vnd.haiku-backgrounds", &backgroundsMessage); + be_roster->Launch("application/x-vnd.haiku-backgrounds", + &backgroundsMessage); break; } @@ -1050,9 +1051,9 @@ ShowImageWindow::MessageReceived(BMessage* message) if (message->FindFloat("offset", &offset) == B_OK && message->FindBool("show", &show) == B_OK) { // Compensate rounding errors with the final placement - if (show) { + if (show) fToolBarView->MoveTo(fToolBarView->Frame().left, 0); - } else { + else { fToolBarView->MoveTo(fToolBarView->Frame().left, offset); fToolBarView->Hide(); } @@ -1174,7 +1175,8 @@ ShowImageWindow::_SaveToFile(BMessage* message) int32 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; } if (i == outCount) @@ -1271,8 +1273,8 @@ ShowImageWindow::_ToggleFullScreen() BScreen screen; fWindowFrame = Frame(); frame = screen.Frame(); - frame.top -= fBar->Bounds().Height()+1; - frame.right += B_V_SCROLL_BAR_WIDTH-1; + frame.top -= fBar->Bounds().Height() + 1; + frame.right += B_V_SCROLL_BAR_WIDTH - 1; frame.bottom += B_H_SCROLL_BAR_HEIGHT; frame.InsetBy(-1, -1); // PEN_SIZE in ShowImageView @@ -1414,7 +1416,7 @@ ShowImageWindow::_Print(BMessage* msg) float width; switch (fPrintOptions.Option()) { case PrintOptions::kFitToPage: { - float w1 = printableRect.Width()+1; + float w1 = printableRect.Width() + 1; float w2 = imageWidth * (printableRect.Height() + 1) / imageHeight; if (w2 < w1) diff --git a/src/apps/showimage/ToolBarView.cpp b/src/apps/showimage/ToolBarView.cpp index e1c2714ffa..a1ec2e20d1 100644 --- a/src/apps/showimage/ToolBarView.cpp +++ b/src/apps/showimage/ToolBarView.cpp @@ -51,8 +51,8 @@ ToolBarView::AddAction(uint32 command, BHandler* target, const BBitmap* icon, void -ToolBarView::AddAction(BMessage* message, BHandler* target, const BBitmap* icon, - const char* toolTipText) +ToolBarView::AddAction(BMessage* message, BHandler* target, + const BBitmap* icon, const char* toolTipText) { BIconButton* button = new BIconButton(NULL, NULL, message, target); button->SetIcon(icon);