29JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4365 6240 6326 6386 6385 28182 28183 6387 6011 6001)
33#if JUCE_INCLUDE_JPEGLIB_CODE || ! defined (JUCE_INCLUDE_JPEGLIB_CODE)
35 typedef unsigned char boolean;
38 JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE (
"-Wconversion",
39 "-Wdeprecated-register",
40 "-Wdeprecated-declarations",
45 "-Wimplicit-fallthrough",
46 "-Wzero-as-null-pointer-constant",
47 "-Wshift-negative-value",
50 #define JPEG_INTERNALS
52 #include "jpglib/jpeglib.h"
54 #include "jpglib/jcapimin.c"
55 #include "jpglib/jcapistd.c"
56 #include "jpglib/jccoefct.c"
57 #include "jpglib/jccolor.c"
59 #include "jpglib/jcdctmgr.c"
61 #include "jpglib/jchuff.c"
63 #include "jpglib/jcinit.c"
64 #include "jpglib/jcmainct.c"
65 #include "jpglib/jcmarker.c"
66 #include "jpglib/jcmaster.c"
67 #include "jpglib/jcomapi.c"
68 #include "jpglib/jcparam.c"
69 #include "jpglib/jcphuff.c"
70 #include "jpglib/jcprepct.c"
71 #include "jpglib/jcsample.c"
72 #include "jpglib/jctrans.c"
73 #include "jpglib/jdapistd.c"
74 #include "jpglib/jdapimin.c"
75 #include "jpglib/jdatasrc.c"
76 #include "jpglib/jdcoefct.c"
78 #include "jpglib/jdcolor.c"
80 #include "jpglib/jddctmgr.c"
83 #include "jpglib/jdhuff.c"
84 #include "jpglib/jdinput.c"
85 #include "jpglib/jdmainct.c"
86 #include "jpglib/jdmarker.c"
87 #include "jpglib/jdmaster.c"
89 #include "jpglib/jdmerge.c"
91 #include "jpglib/jdphuff.c"
92 #include "jpglib/jdpostct.c"
94 #include "jpglib/jdsample.c"
95 #include "jpglib/jdtrans.c"
96 #include "jpglib/jfdctflt.c"
97 #include "jpglib/jfdctint.c"
100 #undef FIX_0_541196100
101 #include "jpglib/jfdctfst.c"
102 #undef FIX_0_541196100
103 #include "jpglib/jidctflt.c"
105 #undef FIX_1_847759065
109 #include "jpglib/jidctfst.c"
111 #undef FIX_1_847759065
114 #include "jpglib/jidctint.c"
115 #include "jpglib/jidctred.c"
116 #include "jpglib/jmemmgr.c"
117 #include "jpglib/jmemnobs.c"
118 #include "jpglib/jquant1.c"
119 #include "jpglib/jquant2.c"
120 #include "jpglib/jutils.c"
121 #include "jpglib/transupp.c"
123 JUCE_END_IGNORE_WARNINGS_GCC_LIKE
125 #define JPEG_INTERNALS
134JUCE_END_IGNORE_WARNINGS_MSVC
139 using namespace jpeglibNamespace;
141 #if ! (JUCE_WINDOWS && (JUCE_MSVC || JUCE_CLANG))
142 using jpeglibNamespace::boolean;
145 static void fatalErrorHandler (
j_common_ptr p) { *((
bool*) (p->client_data)) =
true; }
148 static void silentErrorCallback3 (
j_common_ptr,
char*) {}
154 err.error_exit = fatalErrorHandler;
155 err.emit_message = silentErrorCallback2;
156 err.output_message = silentErrorCallback1;
157 err.format_message = silentErrorCallback3;
158 err.reset_error_mgr = silentErrorCallback1;
162 #if ! JUCE_USING_COREIMAGE_LOADER
180 const int jpegBufferSize = 512;
192 JuceJpegDest*
const dest =
static_cast<JuceJpegDest*
> (
cinfo->dest);
194 const size_t numToWrite = jpegBufferSize - dest->free_in_buffer;
195 dest->output->write (dest->buffer,
numToWrite);
200 JuceJpegDest*
const dest =
static_cast<JuceJpegDest*
> (
cinfo->dest);
204 dest->next_output_byte =
reinterpret_cast<JOCTET*
> (dest->buffer);
205 dest->free_in_buffer = jpegBufferSize;
207 return (
boolean) dest->output->write (dest->buffer, (
size_t)
numToWrite);
212JPEGImageFormat::JPEGImageFormat()
217JPEGImageFormat::~JPEGImageFormat() {}
235 && header[2] == 0xff)
238 #if JUCE_USING_COREIMAGE_LOADER
239 return header[20] ==
'j'
242 && header[23] ==
' ';
248#if JUCE_USING_COREIMAGE_LOADER
254 #if JUCE_USING_COREIMAGE_LOADER
257 using namespace jpeglibNamespace;
258 using namespace JPEGHelpers;
265 if (
mb.getDataSize() > 16)
270 setupSilentErrorHandler (
jerr);
287 jpegDecompStruct.src->next_input_byte =
static_cast<const unsigned char*
> (
mb.getData());
311 image.getProperties()->set (
"originalImageHadAlpha",
false);
316 for (
int y = 0; y < height; ++y)
323 const uint8* src = *buffer;
328 for (
int i = width; --i >= 0;)
330 ((
PixelARGB*) dest)->setARGB (0xff, src[0], src[1], src[2]);
338 for (
int i = width; --i >= 0;)
340 ((
PixelRGB*) dest)->setARGB (0xff, src[0], src[1], src[2]);
364 using namespace jpeglibNamespace;
365 using namespace JPEGHelpers;
372 setupSilentErrorHandler (
jerr);
380 dest.buffer = tempBuffer;
381 dest.next_output_byte = (
JOCTET*) dest.buffer;
382 dest.free_in_buffer = jpegBufferSize;
383 dest.init_destination = jpegWriteInit;
384 dest.empty_output_buffer = jpegWriteFlush;
385 dest.term_destination = jpegWriteTerminate;
423 for (
int i = srcData.width; --i >= 0;)
433 for (
int x = 0; x < srcData.width; ++x)
Represents a colour, also including a transparency value.
Represents a local file or directory.
bool hasFileExtension(StringRef extensionToTest) const
Checks whether the file has a given extension.
Very simple container class to hold a pointer to some data on the heap.
Retrieves a section of an image as raw pixel data, so it can be read or written to.
int pixelStride
The number of bytes between each pixel.
uint8 * getLinePointer(int y) const noexcept
Returns a pointer to the start of a line in the image.
Colour getPixelColour(int x, int y) const noexcept
Returns the colour of a given pixel.
PixelFormat pixelFormat
The format of the data.
Holds a fixed-size bitmap.
@ RGB
< each pixel is a 3-byte packed RGB colour value.
Writes data to an internal memory buffer, which grows as required.
The base class for streams that write data to some kind of destination.
Represents a 32-bit INTERNAL pixel with premultiplied alpha, and can perform compositing operations w...
Represents a 24-bit RGB pixel, and can perform compositing operations on it.
void zerostruct(Type &structure) noexcept
Overwrites a structure or object with zeros.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
unsigned char uint8
A platform-independent 8-bit unsigned integer type.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.