1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

fixed the return value from showNativeMessageBox on the Mac; added support for reading the SMPL block of a Wav file through the metadata; added a couple of missing JUCE_API declarations; optimised the low-quality image rescaling.

This commit is contained in:
jules 2009-06-23 11:10:24 +00:00
parent 749c2be6cb
commit 53fa161c1f
9 changed files with 248 additions and 62 deletions

View file

@ -78,7 +78,7 @@ bool AlertWindow::showNativeDialogBox (const String& title,
juceStringToNS (bodyText),
@"Ok",
isOkCancel ? @"Cancel" : nil,
nil) == 0;
nil) == NSAlertDefaultReturn;
}
//==============================================================================

View file

@ -20306,6 +20306,56 @@ struct BWAVChunk
} PACKED;
struct SMPLChunk
{
struct SampleLoop
{
uint32 identifier;
uint32 type;
uint32 start;
uint32 end;
uint32 fraction;
uint32 playCount;
} PACKED;
uint32 manufacturer;
uint32 product;
uint32 samplePeriod;
uint32 midiUnityNote;
uint32 midiPitchFraction;
uint32 smpteFormat;
uint32 smpteOffset;
uint32 numSampleLoops;
uint32 samplerData;
SampleLoop loops[1];
void copyTo (StringPairArray& values, const int totalSize) const
{
values.set (T("Manufacturer"), String (swapIfBigEndian (manufacturer)));
values.set (T("Product"), String (swapIfBigEndian (product)));
values.set (T("SamplePeriod"), String (swapIfBigEndian (samplePeriod)));
values.set (T("MidiUnityNote"), String (swapIfBigEndian (midiUnityNote)));
values.set (T("MidiPitchFraction"), String (swapIfBigEndian (midiPitchFraction)));
values.set (T("SmpteFormat"), String (swapIfBigEndian (smpteFormat)));
values.set (T("SmpteOffset"), String (swapIfBigEndian (smpteOffset)));
values.set (T("NumSampleLoops"), String (swapIfBigEndian (numSampleLoops)));
values.set (T("SamplerData"), String (swapIfBigEndian (samplerData)));
for (uint32 i = 0; i < numSampleLoops; ++i)
{
if ((uint8*) (loops + (i + 1)) > ((uint8*) this) + totalSize)
break;
values.set (String::formatted (T("Loop%dIdentifier"), i), String (swapIfBigEndian (loops[i].identifier)));
values.set (String::formatted (T("Loop%dType"), i), String (swapIfBigEndian (loops[i].type)));
values.set (String::formatted (T("Loop%dStart"), i), String (swapIfBigEndian (loops[i].start)));
values.set (String::formatted (T("Loop%dEnd"), i), String (swapIfBigEndian (loops[i].end)));
values.set (String::formatted (T("Loop%dFraction"), i), String (swapIfBigEndian (loops[i].fraction)));
values.set (String::formatted (T("Loop%dPlayCount"), i), String (swapIfBigEndian (loops[i].playCount)));
}
}
} PACKED;
#if JUCE_MSVC
#pragma pack (pop)
#endif
@ -20383,15 +20433,18 @@ public:
// Broadcast-wav extension chunk..
BWAVChunk* const bwav = (BWAVChunk*) juce_calloc (jmax (length + 1, (int) sizeof (BWAVChunk)));
if (bwav != 0)
{
input->read (bwav, length);
bwav->copyTo (metadataValues);
juce_free (bwav);
}
input->read (bwav, length);
bwav->copyTo (metadataValues);
juce_free (bwav);
}
else if ((hasGotType && hasGotData) || chunkEnd <= input->getPosition())
else if (chunkType == chunkName ("smpl"))
{
SMPLChunk* const smpl = (SMPLChunk*) juce_calloc (jmax (length + 1, (int) sizeof (SMPLChunk)));
input->read (smpl, length);
smpl->copyTo (metadataValues, length);
juce_free (smpl);
}
else if (chunkEnd <= input->getPosition())
{
break;
}
@ -78941,36 +78994,71 @@ static void transformedImageRender (Image& destImage,
if (quality == Graphics::lowResamplingQuality) // nearest-neighbour..
{
for (int y = 0; y < destClipH; ++y)
if (alpha == 255)
{
double sx = srcX;
double sy = srcY;
DestPixelType* dest = (DestPixelType*) (destPixels + destStride * y);
for (int x = 0; x < destClipW; ++x)
for (int y = 0; y < destClipH; ++y)
{
const int ix = roundDoubleToInt (floor (sx)) - srcClipX;
double sx = srcX;
double sy = srcY;
if (((unsigned int) ix) < (unsigned int) srcClipWidth)
DestPixelType* dest = (DestPixelType*) (destPixels + destStride * y);
for (int x = destClipW; --x >= 0;)
{
const int iy = roundDoubleToInt (floor (sy)) - srcClipY;
const int ix = ((int) sx) - srcClipX;
if (((unsigned int) iy) < (unsigned int) srcClipHeight)
if (((unsigned int) ix) < (unsigned int) srcClipWidth)
{
const SrcPixelType* const src = (const SrcPixelType*) (srcPixels + srcStride * iy + srcPixelStride * ix);
const int iy = ((int) sy) - srcClipY;
dest->blend (*src, alpha);
if (((unsigned int) iy) < (unsigned int) srcClipHeight)
{
const SrcPixelType* const src = (const SrcPixelType*) (srcPixels + srcStride * iy + srcPixelStride * ix);
dest->set (*src);
}
}
++dest;
sx += pixelDX;
sy += pixelDY;
}
++dest;
sx += pixelDX;
sy += pixelDY;
srcX += lineDX;
srcY += lineDY;
}
}
else
{
for (int y = 0; y < destClipH; ++y)
{
double sx = srcX;
double sy = srcY;
srcX += lineDX;
srcY += lineDY;
DestPixelType* dest = (DestPixelType*) (destPixels + destStride * y);
for (int x = destClipW; --x >= 0;)
{
const int ix = ((int) sx) - srcClipX;
if (((unsigned int) ix) < (unsigned int) srcClipWidth)
{
const int iy = ((int) sy) - srcClipY;
if (((unsigned int) iy) < (unsigned int) srcClipHeight)
{
const SrcPixelType* const src = (const SrcPixelType*) (srcPixels + srcStride * iy + srcPixelStride * ix);
dest->blend (*src, alpha);
}
}
++dest;
sx += pixelDX;
sy += pixelDY;
}
srcX += lineDX;
srcY += lineDY;
}
}
}
else
@ -266752,7 +266840,7 @@ bool AlertWindow::showNativeDialogBox (const String& title,
juceStringToNS (bodyText),
@"Ok",
isOkCancel ? @"Cancel" : nil,
nil) == 0;
nil) == NSAlertDefaultReturn;
}
bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& files, const bool canMoveFiles)

View file

@ -669,6 +669,10 @@
#define JUCE_API __declspec (dllimport)
#pragma warning (disable: 4251)
#endif
#elif defined (__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#ifdef JUCE_DLL_BUILD
#define JUCE_API __attribute__ ((visibility("default")))
#endif
#endif
#ifndef JUCE_API
@ -11428,7 +11432,7 @@ public:
bool isObject() const throw() { return type == objectType; }
bool isMethod() const throw() { return type == methodType; }
class identifier
class JUCE_API identifier
{
public:
identifier (const char* const name) throw();
@ -40843,7 +40847,7 @@ public:
@see ImageFileFormat, JPEGImageFormat
*/
class PNGImageFormat : public ImageFileFormat
class JUCE_API PNGImageFormat : public ImageFileFormat
{
public:
@ -40863,7 +40867,7 @@ public:
@see ImageFileFormat, PNGImageFormat
*/
class JPEGImageFormat : public ImageFileFormat
class JUCE_API JPEGImageFormat : public ImageFileFormat
{
public:
@ -53393,7 +53397,7 @@ class WebBrowserComponentInternal;
Windows, probably IE.
*/
class WebBrowserComponent : public Component
class JUCE_API WebBrowserComponent : public Component
{
public:

View file

@ -152,6 +152,58 @@ struct BWAVChunk
} PACKED;
//==============================================================================
struct SMPLChunk
{
struct SampleLoop
{
uint32 identifier;
uint32 type;
uint32 start;
uint32 end;
uint32 fraction;
uint32 playCount;
} PACKED;
uint32 manufacturer;
uint32 product;
uint32 samplePeriod;
uint32 midiUnityNote;
uint32 midiPitchFraction;
uint32 smpteFormat;
uint32 smpteOffset;
uint32 numSampleLoops;
uint32 samplerData;
SampleLoop loops[1];
void copyTo (StringPairArray& values, const int totalSize) const
{
values.set (T("Manufacturer"), String (swapIfBigEndian (manufacturer)));
values.set (T("Product"), String (swapIfBigEndian (product)));
values.set (T("SamplePeriod"), String (swapIfBigEndian (samplePeriod)));
values.set (T("MidiUnityNote"), String (swapIfBigEndian (midiUnityNote)));
values.set (T("MidiPitchFraction"), String (swapIfBigEndian (midiPitchFraction)));
values.set (T("SmpteFormat"), String (swapIfBigEndian (smpteFormat)));
values.set (T("SmpteOffset"), String (swapIfBigEndian (smpteOffset)));
values.set (T("NumSampleLoops"), String (swapIfBigEndian (numSampleLoops)));
values.set (T("SamplerData"), String (swapIfBigEndian (samplerData)));
for (uint32 i = 0; i < numSampleLoops; ++i)
{
if ((uint8*) (loops + (i + 1)) > ((uint8*) this) + totalSize)
break;
values.set (String::formatted (T("Loop%dIdentifier"), i), String (swapIfBigEndian (loops[i].identifier)));
values.set (String::formatted (T("Loop%dType"), i), String (swapIfBigEndian (loops[i].type)));
values.set (String::formatted (T("Loop%dStart"), i), String (swapIfBigEndian (loops[i].start)));
values.set (String::formatted (T("Loop%dEnd"), i), String (swapIfBigEndian (loops[i].end)));
values.set (String::formatted (T("Loop%dFraction"), i), String (swapIfBigEndian (loops[i].fraction)));
values.set (String::formatted (T("Loop%dPlayCount"), i), String (swapIfBigEndian (loops[i].playCount)));
}
}
} PACKED;
#if JUCE_MSVC
#pragma pack (pop)
#endif
@ -231,15 +283,18 @@ public:
// Broadcast-wav extension chunk..
BWAVChunk* const bwav = (BWAVChunk*) juce_calloc (jmax (length + 1, (int) sizeof (BWAVChunk)));
if (bwav != 0)
{
input->read (bwav, length);
bwav->copyTo (metadataValues);
juce_free (bwav);
}
input->read (bwav, length);
bwav->copyTo (metadataValues);
juce_free (bwav);
}
else if ((hasGotType && hasGotData) || chunkEnd <= input->getPosition())
else if (chunkType == chunkName ("smpl"))
{
SMPLChunk* const smpl = (SMPLChunk*) juce_calloc (jmax (length + 1, (int) sizeof (SMPLChunk)));
input->read (smpl, length);
smpl->copyTo (metadataValues, length);
juce_free (smpl);
}
else if (chunkEnd <= input->getPosition())
{
break;
}

View file

@ -47,7 +47,7 @@ class WebBrowserComponentInternal;
Windows, probably IE.
*/
class WebBrowserComponent : public Component
class JUCE_API WebBrowserComponent : public Component
{
public:
//==============================================================================

View file

@ -890,36 +890,71 @@ static void transformedImageRender (Image& destImage,
if (quality == Graphics::lowResamplingQuality) // nearest-neighbour..
{
for (int y = 0; y < destClipH; ++y)
if (alpha == 255)
{
double sx = srcX;
double sy = srcY;
DestPixelType* dest = (DestPixelType*) (destPixels + destStride * y);
for (int x = 0; x < destClipW; ++x)
for (int y = 0; y < destClipH; ++y)
{
const int ix = roundDoubleToInt (floor (sx)) - srcClipX;
double sx = srcX;
double sy = srcY;
if (((unsigned int) ix) < (unsigned int) srcClipWidth)
DestPixelType* dest = (DestPixelType*) (destPixels + destStride * y);
for (int x = destClipW; --x >= 0;)
{
const int iy = roundDoubleToInt (floor (sy)) - srcClipY;
const int ix = ((int) sx) - srcClipX;
if (((unsigned int) iy) < (unsigned int) srcClipHeight)
if (((unsigned int) ix) < (unsigned int) srcClipWidth)
{
const SrcPixelType* const src = (const SrcPixelType*) (srcPixels + srcStride * iy + srcPixelStride * ix);
const int iy = ((int) sy) - srcClipY;
dest->blend (*src, alpha);
if (((unsigned int) iy) < (unsigned int) srcClipHeight)
{
const SrcPixelType* const src = (const SrcPixelType*) (srcPixels + srcStride * iy + srcPixelStride * ix);
dest->set (*src);
}
}
++dest;
sx += pixelDX;
sy += pixelDY;
}
++dest;
sx += pixelDX;
sy += pixelDY;
srcX += lineDX;
srcY += lineDY;
}
}
else
{
for (int y = 0; y < destClipH; ++y)
{
double sx = srcX;
double sy = srcY;
srcX += lineDX;
srcY += lineDY;
DestPixelType* dest = (DestPixelType*) (destPixels + destStride * y);
for (int x = destClipW; --x >= 0;)
{
const int ix = ((int) sx) - srcClipX;
if (((unsigned int) ix) < (unsigned int) srcClipWidth)
{
const int iy = ((int) sy) - srcClipY;
if (((unsigned int) iy) < (unsigned int) srcClipHeight)
{
const SrcPixelType* const src = (const SrcPixelType*) (srcPixels + srcStride * iy + srcPixelStride * ix);
dest->blend (*src, alpha);
}
}
++dest;
sx += pixelDX;
sy += pixelDY;
}
srcX += lineDX;
srcY += lineDY;
}
}
}
else

View file

@ -152,7 +152,7 @@ public:
@see ImageFileFormat, JPEGImageFormat
*/
class PNGImageFormat : public ImageFileFormat
class JUCE_API PNGImageFormat : public ImageFileFormat
{
public:
//==============================================================================
@ -175,7 +175,7 @@ public:
@see ImageFileFormat, PNGImageFormat
*/
class JPEGImageFormat : public ImageFileFormat
class JUCE_API JPEGImageFormat : public ImageFileFormat
{
public:
//==============================================================================

View file

@ -121,6 +121,10 @@
#define JUCE_API __declspec (dllimport)
#pragma warning (disable: 4251)
#endif
#elif defined (__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#ifdef JUCE_DLL_BUILD
#define JUCE_API __attribute__ ((visibility("default")))
#endif
#endif
#ifndef JUCE_API

View file

@ -97,7 +97,7 @@ public:
bool isMethod() const throw() { return type == methodType; }
//==============================================================================
class identifier
class JUCE_API identifier
{
public:
identifier (const char* const name) throw();