Browse Source

Introjucer: better icon generation.

tags/2021-05-28
jules 13 years ago
parent
commit
ff3b616759
11 changed files with 33 additions and 17 deletions
  1. BIN
      extras/Introjucer/Builds/VisualStudio2005/icon.ico
  2. BIN
      extras/Introjucer/Builds/VisualStudio2008/icon.ico
  3. BIN
      extras/Introjucer/Builds/VisualStudio2010/icon.ico
  4. +16
    -15
      extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h
  5. +15
    -2
      extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp
  6. +2
    -0
      extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h
  7. BIN
      extras/JuceDemo/Builds/VisualStudio2005/icon.ico
  8. BIN
      extras/JuceDemo/Builds/VisualStudio2008/icon.ico
  9. BIN
      extras/JuceDemo/Builds/VisualStudio2010/icon.ico
  10. BIN
      extras/the jucer/Builds/VisualStudio2008/icon.ico
  11. BIN
      extras/the jucer/Builds/VisualStudio2010/icon.ico

BIN
extras/Introjucer/Builds/VisualStudio2005/icon.ico View File

Before After

BIN
extras/Introjucer/Builds/VisualStudio2008/icon.ico View File

Before After

BIN
extras/Introjucer/Builds/VisualStudio2010/icon.ico View File

Before After

+ 16
- 15
extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h View File

@@ -337,20 +337,23 @@ private:
static Image fixMacIconImageSize (Image& image) static Image fixMacIconImageSize (Image& image)
{ {
const int validSizes[] = { 16, 32, 48, 128 };
const int w = image.getWidth(); const int w = image.getWidth();
const int h = image.getHeight(); const int h = image.getHeight();
if (w != h || (w != 16 && w != 32 && w != 48 && w != 64))
int bestSize = 16;
for (int i = 0; i < numElementsInArray (validSizes); ++i)
{ {
const int newSize = w >= 128 ? 128 : (w >= 64 ? 64 : (w >= 32 ? 32 : 16));
Image newIm (Image::ARGB, newSize, newSize, true, SoftwareImageType());
Graphics g (newIm);
g.drawImageWithin (image, 0, 0, newSize, newSize,
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false);
return newIm;
if (w == h && w == validSizes[i])
return image;
if (jmax (w, h) > validSizes[i])
bestSize = validSizes[i];
} }
return image;
return rescaleImageForIcon (image, bestSize);
} }
void writeIcnsFile (const Array<Image>& images, OutputStream& out) const void writeIcnsFile (const Array<Image>& images, OutputStream& out) const
@@ -363,17 +366,15 @@ private:
const int w = image.getWidth(); const int w = image.getWidth();
const int h = image.getHeight(); const int h = image.getHeight();
jassert (w == h);
const char* type = nullptr; const char* type = nullptr;
const char* maskType = nullptr; const char* maskType = nullptr;
if (w == h)
{
if (w == 16) { type = "is32"; maskType = "s8mk"; }
if (w == 32) { type = "il32"; maskType = "l8mk"; }
if (w == 48) { type = "ih32"; maskType = "h8mk"; }
if (w == 128) { type = "it32"; maskType = "t8mk"; }
}
if (w == 16) { type = "is32"; maskType = "s8mk"; }
if (w == 32) { type = "il32"; maskType = "l8mk"; }
if (w == 48) { type = "ih32"; maskType = "h8mk"; }
if (w == 128) { type = "it32"; maskType = "t8mk"; }
if (type != nullptr) if (type != nullptr)
{ {


+ 15
- 2
extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.cpp View File

@@ -408,11 +408,23 @@ Image ProjectExporter::getBestIconForSize (int size, bool returnNullIfNothingBig
im = im1.isValid() ? im1 : im2; im = im1.isValid() ? im1 : im2;
} }
if (returnNullIfNothingBigEnough && im.getWidth() < size && im.getHeight() < size)
return Image::null;
return rescaleImageForIcon (im, size);
}
Image ProjectExporter::rescaleImageForIcon (Image im, const int size)
{
im = SoftwareImageType().convert (im);
if (size == im.getWidth() && size == im.getHeight()) if (size == im.getWidth() && size == im.getHeight())
return im; return im;
if (returnNullIfNothingBigEnough && im.getWidth() < size && im.getHeight() < size)
return Image::null;
// (scale it down in stages for better resampling)
while (im.getWidth() > 2 * size && im.getHeight() > 2 * size)
im = im.rescaled (im.getWidth() / 2,
im.getHeight() / 2);
Image newIm (Image::ARGB, size, size, true, SoftwareImageType()); Image newIm (Image::ARGB, size, size, true, SoftwareImageType());
Graphics g (newIm); Graphics g (newIm);
@@ -421,6 +433,7 @@ Image ProjectExporter::getBestIconForSize (int size, bool returnNullIfNothingBig
return newIm; return newIm;
} }
//============================================================================== //==============================================================================
ProjectExporter::ConfigIterator::ConfigIterator (ProjectExporter& exporter_) ProjectExporter::ConfigIterator::ConfigIterator (ProjectExporter& exporter_)
: index (-1), exporter (exporter_) : index (-1), exporter (exporter_)


+ 2
- 0
extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h View File

@@ -318,6 +318,8 @@ protected:
} }
} }
static Image rescaleImageForIcon (Image image, int iconSize);
private: private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectExporter); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectExporter);
}; };


BIN
extras/JuceDemo/Builds/VisualStudio2005/icon.ico View File

Before After

BIN
extras/JuceDemo/Builds/VisualStudio2008/icon.ico View File

Before After

BIN
extras/JuceDemo/Builds/VisualStudio2010/icon.ico View File

Before After

BIN
extras/the jucer/Builds/VisualStudio2008/icon.ico View File

Before After

BIN
extras/the jucer/Builds/VisualStudio2010/icon.ico View File

Before After

Loading…
Cancel
Save