From 9524149ce1980ac9a906aaadd29fa2531c26be70 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Thu, 29 Apr 2010 15:02:43 +0100 Subject: [PATCH] Minor clean-ups. --- juce_amalgamated.cpp | 171 +++++++----------- juce_amalgamated.h | 60 +++--- .../graphics/effects/juce_DropShadowEffect.h | 8 +- src/gui/graphics/effects/juce_GlowEffect.h | 2 +- .../effects/juce_ReduceOpacityEffect.h | 4 +- src/gui/graphics/fonts/juce_Font.h | 2 +- .../graphics/geometry/juce_AffineTransform.h | 44 ++--- .../image_file_formats/juce_GIFLoader.cpp | 29 +-- .../image_file_formats/juce_JPEGLoader.cpp | 42 ++++- .../image_file_formats/juce_PNGLoader.cpp | 26 ++- .../graphics/imaging/juce_ImageFileFormat.cpp | 82 --------- 11 files changed, 190 insertions(+), 280 deletions(-) diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index cfc1dc44bf..7a1f52d46e 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -91139,86 +91139,6 @@ private: #endif // __JUCE_GIFLOADER_JUCEHEADER__ /*** End of inlined file: juce_GIFLoader.h ***/ -Image* juce_loadPNGImageFromStream (InputStream& inputStream); -bool juce_writePNGImageToStream (const Image& image, OutputStream& out); - -PNGImageFormat::PNGImageFormat() {} -PNGImageFormat::~PNGImageFormat() {} - -const String PNGImageFormat::getFormatName() -{ - return "PNG"; -} - -bool PNGImageFormat::canUnderstand (InputStream& in) -{ - const int bytesNeeded = 4; - char header [bytesNeeded]; - - return in.read (header, bytesNeeded) == bytesNeeded - && header[1] == 'P' - && header[2] == 'N' - && header[3] == 'G'; -} - -Image* PNGImageFormat::decodeImage (InputStream& in) -{ - return juce_loadPNGImageFromStream (in); -} - -bool PNGImageFormat::writeImageToStream (const Image& sourceImage, - OutputStream& destStream) -{ - return juce_writePNGImageToStream (sourceImage, destStream); -} - -Image* juce_loadJPEGImageFromStream (InputStream& inputStream); -bool juce_writeJPEGImageToStream (const Image& image, OutputStream& out, float quality); - -JPEGImageFormat::JPEGImageFormat() - : quality (-1.0f) -{ -} - -JPEGImageFormat::~JPEGImageFormat() {} - -void JPEGImageFormat::setQuality (const float newQuality) -{ - quality = newQuality; -} - -const String JPEGImageFormat::getFormatName() -{ - return "JPEG"; -} - -bool JPEGImageFormat::canUnderstand (InputStream& in) -{ - const int bytesNeeded = 10; - uint8 header [bytesNeeded]; - - if (in.read (header, bytesNeeded) == bytesNeeded) - { - return header[0] == 0xff - && header[1] == 0xd8 - && header[2] == 0xff - && (header[3] == 0xe0 || header[3] == 0xe1); - } - - return false; -} - -Image* JPEGImageFormat::decodeImage (InputStream& in) -{ - return juce_loadJPEGImageFromStream (in); -} - -bool JPEGImageFormat::writeImageToStream (const Image& sourceImage, - OutputStream& destStream) -{ - return juce_writeJPEGImageToStream (sourceImage, destStream, quality); -} - class GIFImageFormat : public ImageFileFormat { public: @@ -91706,16 +91626,10 @@ bool GIFLoader::readImage (const int width, const int height, { switch (pass) { - case 0: - case 1: - ypos += 8; - break; - case 2: - ypos += 4; - break; - case 3: - ypos += 2; - break; + case 0: + case 1: ypos += 8; break; + case 2: ypos += 4; break; + case 3: ypos += 2; break; } while (ypos >= height) @@ -91724,17 +91638,10 @@ bool GIFLoader::readImage (const int width, const int height, switch (pass) { - case 1: - ypos = 4; - break; - case 2: - ypos = 2; - break; - case 3: - ypos = 1; - break; - default: - return true; + case 1: ypos = 4; break; + case 2: ypos = 2; break; + case 3: ypos = 1; break; + default: return true; } } } @@ -187885,7 +187792,40 @@ namespace JPEGHelpers } } -Image* juce_loadJPEGImageFromStream (InputStream& in) +JPEGImageFormat::JPEGImageFormat() + : quality (-1.0f) +{ +} + +JPEGImageFormat::~JPEGImageFormat() {} + +void JPEGImageFormat::setQuality (const float newQuality) +{ + quality = newQuality; +} + +const String JPEGImageFormat::getFormatName() +{ + return "JPEG"; +} + +bool JPEGImageFormat::canUnderstand (InputStream& in) +{ + const int bytesNeeded = 10; + uint8 header [bytesNeeded]; + + if (in.read (header, bytesNeeded) == bytesNeeded) + { + return header[0] == 0xff + && header[1] == 0xd8 + && header[2] == 0xff + && (header[3] == 0xe0 || header[3] == 0xe1); + } + + return false; +} + +Image* JPEGImageFormat::decodeImage (InputStream& in) { using namespace jpeglibNamespace; using namespace JPEGHelpers; @@ -187982,9 +187922,7 @@ Image* juce_loadJPEGImageFromStream (InputStream& in) return image; } -bool juce_writeJPEGImageToStream (const Image& image, - OutputStream& out, - float quality) +bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out) { using namespace jpeglibNamespace; using namespace JPEGHelpers; @@ -210425,7 +210363,26 @@ namespace PNGHelpers } } -Image* juce_loadPNGImageFromStream (InputStream& in) +PNGImageFormat::PNGImageFormat() {} +PNGImageFormat::~PNGImageFormat() {} + +const String PNGImageFormat::getFormatName() +{ + return "PNG"; +} + +bool PNGImageFormat::canUnderstand (InputStream& in) +{ + const int bytesNeeded = 4; + char header [bytesNeeded]; + + return in.read (header, bytesNeeded) == bytesNeeded + && header[1] == 'P' + && header[2] == 'N' + && header[3] == 'G'; +} + +Image* PNGImageFormat::decodeImage (InputStream& in) { using namespace pnglibNamespace; Image* image = 0; @@ -210536,7 +210493,7 @@ Image* juce_loadPNGImageFromStream (InputStream& in) return image; } -bool juce_writePNGImageToStream (const Image& image, OutputStream& out) +bool PNGImageFormat::writeImageToStream (const Image& image, OutputStream& out) { using namespace pnglibNamespace; const int width = image.getWidth(); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 999f0349de..d55db71207 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -9546,8 +9546,8 @@ public: AffineTransform (const AffineTransform& other) throw(); - AffineTransform (const float mat00, const float mat01, const float mat02, - const float mat10, const float mat11, const float mat12) throw(); + AffineTransform (float mat00, float mat01, float mat02, + float mat10, float mat11, float mat12) throw(); AffineTransform& operator= (const AffineTransform& other) throw(); @@ -9563,32 +9563,32 @@ public: void transformPoint (double& x, double& y) const throw(); - const AffineTransform translated (const float deltaX, - const float deltaY) const throw(); + const AffineTransform translated (float deltaX, + float deltaY) const throw(); - static const AffineTransform translation (const float deltaX, - const float deltaY) throw(); + static const AffineTransform translation (float deltaX, + float deltaY) throw(); - const AffineTransform rotated (const float angleInRadians) const throw(); + const AffineTransform rotated (float angleInRadians) const throw(); - const AffineTransform rotated (const float angleInRadians, - const float pivotX, - const float pivotY) const throw(); + const AffineTransform rotated (float angleInRadians, + float pivotX, + float pivotY) const throw(); - static const AffineTransform rotation (const float angleInRadians) throw(); + static const AffineTransform rotation (float angleInRadians) throw(); - static const AffineTransform rotation (const float angleInRadians, - const float pivotX, - const float pivotY) throw(); + static const AffineTransform rotation (float angleInRadians, + float pivotX, + float pivotY) throw(); - const AffineTransform scaled (const float factorX, - const float factorY) const throw(); + const AffineTransform scaled (float factorX, + float factorY) const throw(); - static const AffineTransform scale (const float factorX, - const float factorY) throw(); + static const AffineTransform scale (float factorX, + float factorY) throw(); - const AffineTransform sheared (const float shearX, - const float shearY) const throw(); + const AffineTransform sheared (float shearX, + float shearY) const throw(); const AffineTransform inverted() const throw(); @@ -9611,8 +9611,8 @@ public: private: - const AffineTransform followedBy (const float mat00, const float mat01, const float mat02, - const float mat10, const float mat11, const float mat12) const throw(); + const AffineTransform followedBy (float mat00, float mat01, float mat02, + float mat10, float mat11, float mat12) const throw(); }; #endif // __JUCE_AFFINETRANSFORM_JUCEHEADER__ @@ -11188,7 +11188,7 @@ public: int getStyleFlags() const throw() { return font->styleFlags; } - void setStyleFlags (const int newFlags) throw(); + void setStyleFlags (int newFlags) throw(); void setBold (bool shouldBeBold) throw(); bool isBold() const throw(); @@ -20098,10 +20098,10 @@ public: ~DropShadowEffect(); - void setShadowProperties (const float newRadius, - const float newOpacity, - const int newShadowOffsetX, - const int newShadowOffsetY); + void setShadowProperties (float newRadius, + float newOpacity, + int newShadowOffsetX, + int newShadowOffsetY); void applyEffect (Image& sourceImage, Graphics& destContext); @@ -28217,7 +28217,7 @@ public: ~GlowEffect(); - void setGlowProperties (const float newRadius, + void setGlowProperties (float newRadius, const Colour& newColour); void applyEffect (Image& sourceImage, Graphics& destContext); @@ -28247,11 +28247,11 @@ class JUCE_API ReduceOpacityEffect : public ImageEffectFilter { public: - ReduceOpacityEffect (const float opacity = 1.0f); + ReduceOpacityEffect (float opacity = 1.0f); ~ReduceOpacityEffect(); - void setOpacity (const float newOpacity); + void setOpacity (float newOpacity); void applyEffect (Image& sourceImage, Graphics& destContext); diff --git a/src/gui/graphics/effects/juce_DropShadowEffect.h b/src/gui/graphics/effects/juce_DropShadowEffect.h index f1905acfed..06fa39d316 100644 --- a/src/gui/graphics/effects/juce_DropShadowEffect.h +++ b/src/gui/graphics/effects/juce_DropShadowEffect.h @@ -69,10 +69,10 @@ public: @param newShadowOffsetY allows the shadow to be shifted in relation to the component's contents */ - void setShadowProperties (const float newRadius, - const float newOpacity, - const int newShadowOffsetX, - const int newShadowOffsetY); + void setShadowProperties (float newRadius, + float newOpacity, + int newShadowOffsetX, + int newShadowOffsetY); //============================================================================== diff --git a/src/gui/graphics/effects/juce_GlowEffect.h b/src/gui/graphics/effects/juce_GlowEffect.h index e2e4a9ecea..305feb431b 100644 --- a/src/gui/graphics/effects/juce_GlowEffect.h +++ b/src/gui/graphics/effects/juce_GlowEffect.h @@ -57,7 +57,7 @@ public: used to render it (for a less intense glow, lower the colour's opacity). */ - void setGlowProperties (const float newRadius, + void setGlowProperties (float newRadius, const Colour& newColour); diff --git a/src/gui/graphics/effects/juce_ReduceOpacityEffect.h b/src/gui/graphics/effects/juce_ReduceOpacityEffect.h index eea12beb36..7734dd303f 100644 --- a/src/gui/graphics/effects/juce_ReduceOpacityEffect.h +++ b/src/gui/graphics/effects/juce_ReduceOpacityEffect.h @@ -47,7 +47,7 @@ public: The opacity of the component to which the effect is applied will be scaled by the given factor (in the range 0 to 1.0f). */ - ReduceOpacityEffect (const float opacity = 1.0f); + ReduceOpacityEffect (float opacity = 1.0f); /** Destructor. */ ~ReduceOpacityEffect(); @@ -56,7 +56,7 @@ public: @param newOpacity should be between 0 and 1.0f */ - void setOpacity (const float newOpacity); + void setOpacity (float newOpacity); //============================================================================== diff --git a/src/gui/graphics/fonts/juce_Font.h b/src/gui/graphics/fonts/juce_Font.h index 2e83284d14..75a4be35fb 100644 --- a/src/gui/graphics/fonts/juce_Font.h +++ b/src/gui/graphics/fonts/juce_Font.h @@ -225,7 +225,7 @@ public: enum, to set the font's properties @see FontStyleFlags */ - void setStyleFlags (const int newFlags) throw(); + void setStyleFlags (int newFlags) throw(); //============================================================================== /** Makes the font bold or non-bold. */ diff --git a/src/gui/graphics/geometry/juce_AffineTransform.h b/src/gui/graphics/geometry/juce_AffineTransform.h index 3cf409d508..eda4ae902d 100644 --- a/src/gui/graphics/geometry/juce_AffineTransform.h +++ b/src/gui/graphics/geometry/juce_AffineTransform.h @@ -56,8 +56,8 @@ public: (mat10 mat11 mat12) ( 0 0 1 ) */ - AffineTransform (const float mat00, const float mat01, const float mat02, - const float mat10, const float mat11, const float mat12) throw(); + AffineTransform (float mat00, float mat01, float mat02, + float mat10, float mat11, float mat12) throw(); /** Copies from another AffineTransform object */ AffineTransform& operator= (const AffineTransform& other) throw(); @@ -90,54 +90,54 @@ public: //============================================================================== /** Returns a new transform which is the same as this one followed by a translation. */ - const AffineTransform translated (const float deltaX, - const float deltaY) const throw(); + const AffineTransform translated (float deltaX, + float deltaY) const throw(); /** Returns a new transform which is a translation. */ - static const AffineTransform translation (const float deltaX, - const float deltaY) throw(); + static const AffineTransform translation (float deltaX, + float deltaY) throw(); /** Returns a transform which is the same as this one followed by a rotation. The rotation is specified by a number of radians to rotate clockwise, centred around the origin (0, 0). */ - const AffineTransform rotated (const float angleInRadians) const throw(); + const AffineTransform rotated (float angleInRadians) const throw(); /** Returns a transform which is the same as this one followed by a rotation about a given point. The rotation is specified by a number of radians to rotate clockwise, centred around the co-ordinates passed in. */ - const AffineTransform rotated (const float angleInRadians, - const float pivotX, - const float pivotY) const throw(); + const AffineTransform rotated (float angleInRadians, + float pivotX, + float pivotY) const throw(); /** Returns a new transform which is a rotation about (0, 0). */ - static const AffineTransform rotation (const float angleInRadians) throw(); + static const AffineTransform rotation (float angleInRadians) throw(); /** Returns a new transform which is a rotation about a given point. */ - static const AffineTransform rotation (const float angleInRadians, - const float pivotX, - const float pivotY) throw(); + static const AffineTransform rotation (float angleInRadians, + float pivotX, + float pivotY) throw(); /** Returns a transform which is the same as this one followed by a re-scaling. The scaling is centred around the origin (0, 0). */ - const AffineTransform scaled (const float factorX, - const float factorY) const throw(); + const AffineTransform scaled (float factorX, + float factorY) const throw(); /** Returns a new transform which is a re-scale about the origin. */ - static const AffineTransform scale (const float factorX, - const float factorY) throw(); + static const AffineTransform scale (float factorX, + float factorY) throw(); /** Returns a transform which is the same as this one followed by a shear. The shear is centred around the origin (0, 0). */ - const AffineTransform sheared (const float shearX, - const float shearY) const throw(); + const AffineTransform sheared (float shearX, + float shearY) const throw(); /** Returns a matrix which is the inverse operation of this one. @@ -185,8 +185,8 @@ public: private: //============================================================================== - const AffineTransform followedBy (const float mat00, const float mat01, const float mat02, - const float mat10, const float mat11, const float mat12) const throw(); + const AffineTransform followedBy (float mat00, float mat01, float mat02, + float mat10, float mat11, float mat12) const throw(); }; #endif // __JUCE_AFFINETRANSFORM_JUCEHEADER__ diff --git a/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp index 1cc6725a82..009c6f4d11 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_GIFLoader.cpp @@ -418,16 +418,10 @@ bool GIFLoader::readImage (const int width, const int height, { switch (pass) { - case 0: - case 1: - ypos += 8; - break; - case 2: - ypos += 4; - break; - case 3: - ypos += 2; - break; + case 0: + case 1: ypos += 8; break; + case 2: ypos += 4; break; + case 3: ypos += 2; break; } while (ypos >= height) @@ -436,17 +430,10 @@ bool GIFLoader::readImage (const int width, const int height, switch (pass) { - case 1: - ypos = 4; - break; - case 2: - ypos = 2; - break; - case 3: - ypos = 1; - break; - default: - return true; + case 1: ypos = 4; break; + case 2: ypos = 2; break; + case 3: ypos = 1; break; + default: return true; } } } diff --git a/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp index 7fcd354726..a5a62648c1 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_JPEGLoader.cpp @@ -126,7 +126,7 @@ namespace jpeglibNamespace BEGIN_JUCE_NAMESPACE -#include "../juce_Image.h" +#include "../juce_ImageFileFormat.h" #include "../../../../io/streams/juce_InputStream.h" #include "../../../../io/streams/juce_OutputStream.h" #include "../../colour/juce_PixelFormats.h" @@ -216,7 +216,40 @@ namespace JPEGHelpers } //============================================================================== -Image* juce_loadJPEGImageFromStream (InputStream& in) +JPEGImageFormat::JPEGImageFormat() + : quality (-1.0f) +{ +} + +JPEGImageFormat::~JPEGImageFormat() {} + +void JPEGImageFormat::setQuality (const float newQuality) +{ + quality = newQuality; +} + +const String JPEGImageFormat::getFormatName() +{ + return "JPEG"; +} + +bool JPEGImageFormat::canUnderstand (InputStream& in) +{ + const int bytesNeeded = 10; + uint8 header [bytesNeeded]; + + if (in.read (header, bytesNeeded) == bytesNeeded) + { + return header[0] == 0xff + && header[1] == 0xd8 + && header[2] == 0xff + && (header[3] == 0xe0 || header[3] == 0xe1); + } + + return false; +} + +Image* JPEGImageFormat::decodeImage (InputStream& in) { using namespace jpeglibNamespace; using namespace JPEGHelpers; @@ -313,10 +346,7 @@ Image* juce_loadJPEGImageFromStream (InputStream& in) return image; } -//============================================================================== -bool juce_writeJPEGImageToStream (const Image& image, - OutputStream& out, - float quality) +bool JPEGImageFormat::writeImageToStream (const Image& image, OutputStream& out) { using namespace jpeglibNamespace; using namespace JPEGHelpers; diff --git a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp index 1eabe09dc7..79572b463f 100644 --- a/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp +++ b/src/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp @@ -99,7 +99,7 @@ namespace pnglibNamespace BEGIN_JUCE_NAMESPACE -#include "../juce_Image.h" +#include "../juce_ImageFileFormat.h" #include "../../../../io/streams/juce_InputStream.h" #include "../../../../io/streams/juce_OutputStream.h" #include "../../colour/juce_PixelFormats.h" @@ -132,7 +132,26 @@ namespace PNGHelpers } //============================================================================== -Image* juce_loadPNGImageFromStream (InputStream& in) +PNGImageFormat::PNGImageFormat() {} +PNGImageFormat::~PNGImageFormat() {} + +const String PNGImageFormat::getFormatName() +{ + return "PNG"; +} + +bool PNGImageFormat::canUnderstand (InputStream& in) +{ + const int bytesNeeded = 4; + char header [bytesNeeded]; + + return in.read (header, bytesNeeded) == bytesNeeded + && header[1] == 'P' + && header[2] == 'N' + && header[3] == 'G'; +} + +Image* PNGImageFormat::decodeImage (InputStream& in) { using namespace pnglibNamespace; Image* image = 0; @@ -243,8 +262,7 @@ Image* juce_loadPNGImageFromStream (InputStream& in) return image; } -//============================================================================== -bool juce_writePNGImageToStream (const Image& image, OutputStream& out) +bool PNGImageFormat::writeImageToStream (const Image& image, OutputStream& out) { using namespace pnglibNamespace; const int width = image.getWidth(); diff --git a/src/gui/graphics/imaging/juce_ImageFileFormat.cpp b/src/gui/graphics/imaging/juce_ImageFileFormat.cpp index d4e7fad2a9..f6554d7539 100644 --- a/src/gui/graphics/imaging/juce_ImageFileFormat.cpp +++ b/src/gui/graphics/imaging/juce_ImageFileFormat.cpp @@ -33,88 +33,6 @@ BEGIN_JUCE_NAMESPACE #include "../../../io/streams/juce_BufferedInputStream.h" #include "image_file_formats/juce_GIFLoader.h" -//============================================================================== -Image* juce_loadPNGImageFromStream (InputStream& inputStream); -bool juce_writePNGImageToStream (const Image& image, OutputStream& out); - -PNGImageFormat::PNGImageFormat() {} -PNGImageFormat::~PNGImageFormat() {} - -const String PNGImageFormat::getFormatName() -{ - return "PNG"; -} - -bool PNGImageFormat::canUnderstand (InputStream& in) -{ - const int bytesNeeded = 4; - char header [bytesNeeded]; - - return in.read (header, bytesNeeded) == bytesNeeded - && header[1] == 'P' - && header[2] == 'N' - && header[3] == 'G'; -} - -Image* PNGImageFormat::decodeImage (InputStream& in) -{ - return juce_loadPNGImageFromStream (in); -} - -bool PNGImageFormat::writeImageToStream (const Image& sourceImage, - OutputStream& destStream) -{ - return juce_writePNGImageToStream (sourceImage, destStream); -} - -//============================================================================== -Image* juce_loadJPEGImageFromStream (InputStream& inputStream); -bool juce_writeJPEGImageToStream (const Image& image, OutputStream& out, float quality); - -JPEGImageFormat::JPEGImageFormat() - : quality (-1.0f) -{ -} - -JPEGImageFormat::~JPEGImageFormat() {} - -void JPEGImageFormat::setQuality (const float newQuality) -{ - quality = newQuality; -} - -const String JPEGImageFormat::getFormatName() -{ - return "JPEG"; -} - -bool JPEGImageFormat::canUnderstand (InputStream& in) -{ - const int bytesNeeded = 10; - uint8 header [bytesNeeded]; - - if (in.read (header, bytesNeeded) == bytesNeeded) - { - return header[0] == 0xff - && header[1] == 0xd8 - && header[2] == 0xff - && (header[3] == 0xe0 || header[3] == 0xe1); - } - - return false; -} - -Image* JPEGImageFormat::decodeImage (InputStream& in) -{ - return juce_loadJPEGImageFromStream (in); -} - -bool JPEGImageFormat::writeImageToStream (const Image& sourceImage, - OutputStream& destStream) -{ - return juce_writeJPEGImageToStream (sourceImage, destStream, quality); -} - //============================================================================== class GIFImageFormat : public ImageFileFormat