JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_ImageFileFormat.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
41class JUCE_API ImageFileFormat
42{
43protected:
44 //==============================================================================
46 ImageFileFormat() = default;
47
48public:
50 virtual ~ImageFileFormat() = default;
51
52 //==============================================================================
57 virtual String getFormatName() = 0;
58
69 virtual bool canUnderstand (InputStream& input) = 0;
70
72 virtual bool usesFileExtension (const File& possibleFile) = 0;
73
85 virtual Image decodeImage (InputStream& input) = 0;
86
87 //==============================================================================
95 virtual bool writeImageToStream (const Image& sourceImage,
96 OutputStream& destStream) = 0;
97
98 //==============================================================================
104 static ImageFileFormat* findImageFormatForStream (InputStream& input);
105
110 static ImageFileFormat* findImageFormatForFileExtension (const File& file);
111
112 //==============================================================================
120 static Image loadFrom (InputStream& input);
121
129 static Image loadFrom (const File& file);
130
138 static Image loadFrom (const void* rawData,
139 size_t numBytesOfData);
140};
141
142//==============================================================================
150class JUCE_API PNGImageFormat : public ImageFileFormat
151{
152public:
153 //==============================================================================
155 ~PNGImageFormat() override;
156
157 //==============================================================================
158 String getFormatName() override;
159 bool usesFileExtension (const File&) override;
160 bool canUnderstand (InputStream&) override;
161 Image decodeImage (InputStream&) override;
162 bool writeImageToStream (const Image&, OutputStream&) override;
163};
164
165
166//==============================================================================
174class JUCE_API JPEGImageFormat : public ImageFileFormat
175{
176public:
177 //==============================================================================
179 ~JPEGImageFormat() override;
180
181 //==============================================================================
187 void setQuality (float newQuality);
188
189 //==============================================================================
190 String getFormatName() override;
191 bool usesFileExtension (const File&) override;
192 bool canUnderstand (InputStream&) override;
193 Image decodeImage (InputStream&) override;
194 bool writeImageToStream (const Image&, OutputStream&) override;
195
196private:
197 float quality;
198};
199
200//==============================================================================
208class JUCE_API GIFImageFormat : public ImageFileFormat
209{
210public:
211 //==============================================================================
213 ~GIFImageFormat() override;
214
215 //==============================================================================
216 String getFormatName() override;
217 bool usesFileExtension (const File&) override;
218 bool canUnderstand (InputStream&) override;
219 Image decodeImage (InputStream&) override;
220 bool writeImageToStream (const Image&, OutputStream&) override;
221};
222
223} // namespace juce
Represents a local file or directory.
Definition juce_File.h:45
A subclass of ImageFileFormat for reading GIF files.
Base-class for codecs that can read and write image file formats such as PNG, JPEG,...
virtual bool canUnderstand(InputStream &input)=0
Returns true if the given stream seems to contain data that this format understands.
virtual String getFormatName()=0
Returns a description of this file format.
virtual Image decodeImage(InputStream &input)=0
Tries to decode and return an image from the given stream.
virtual bool usesFileExtension(const File &possibleFile)=0
Returns true if this format uses the file extension of the given file.
ImageFileFormat()=default
Creates an ImageFormat.
virtual ~ImageFileFormat()=default
Destructor.
virtual bool writeImageToStream(const Image &sourceImage, OutputStream &destStream)=0
Attempts to write an image to a stream.
Holds a fixed-size bitmap.
Definition juce_Image.h:58
The base class for streams that read data.
A subclass of ImageFileFormat for reading and writing JPEG files.
The base class for streams that write data to some kind of destination.
A subclass of ImageFileFormat for reading and writing PNG files.
The JUCE String class!
Definition juce_String.h:53
JUCE Namespace.