38void ImagePreviewComponent::getThumbSize (
int& w,
int& h)
const
43 auto scale =
jmin (1.0,
53 if (fileToLoad != file)
64 currentThumbnail =
Image();
65 currentDetails.
clear();
74 currentThumbnail = format->decodeImage (in);
78 auto w = currentThumbnail.
getWidth();
83 << format->getFormatName() <<
"\n"
84 << w <<
" x " << h <<
" pixels\n"
89 currentThumbnail = currentThumbnail.
rescaled (w, h);
101 auto w = currentThumbnail.
getWidth();
123 return std::make_unique<AccessibilityHandler> (*
this, AccessibilityRole::image);
int proportionOfWidth(float proportion) const noexcept
Returns a proportion of the component's width.
int getHeight() const noexcept
Returns the component's height in pixels.
void repaint()
Marks the whole component as needing to be redrawn.
int getWidth() const noexcept
Returns the component's width in pixels.
Represents a local file or directory.
bool existsAsFile() const
Checks whether the file exists and is a file rather than a directory.
int64 getSize() const
Returns the size of the file in bytes.
String getFileName() const
Returns the last section of the pathname.
static String descriptionOfSizeInBytes(int64 bytes)
Utility function to convert a file size in bytes to a neat string description.
A graphics context, used for drawing a component or image.
void drawFittedText(const String &text, int x, int y, int width, int height, Justification justificationFlags, int maximumNumberOfLines, float minimumHorizontalScale=0.0f) const
Tries to draw a text string inside a given space.
void setFont(const Font &newFont)
Changes the font to use for subsequent text-drawing functions.
void drawImageWithin(const Image &imageToDraw, int destX, int destY, int destWidth, int destHeight, RectanglePlacement placementWithinTarget, bool fillAlphaChannelWithCurrentBrush=false) const
Draws an image to fit within a designated rectangle.
ImagePreviewComponent()
Creates an ImagePreviewComponent.
void selectedFileChanged(const File &newSelectedFile) override
Called to indicate that the user's currently selected file has changed.
void paint(Graphics &) override
Components can override this method to draw their content.
~ImagePreviewComponent() override
Destructor.
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Override this method to return a custom AccessibilityHandler for this component.
void timerCallback() override
The user-defined callback routine that actually gets called periodically.
Holds a fixed-size bitmap.
int getWidth() const noexcept
Returns the image's width (in pixels).
int getHeight() const noexcept
Returns the image's height (in pixels).
Image rescaled(int newWidth, int newHeight, Graphics::ResamplingQuality quality=Graphics::mediumResamplingQuality) const
Returns a rescaled version of this image.
bool isValid() const noexcept
Returns true if this image isn't null.
@ centredTop
Indicates that the item should be centred horizontally and placed at the top.
@ onlyReduceInSize
Indicates that the source rectangle can be reduced in size if required, but should never be made larg...
@ centred
A shorthand value that is equivalent to (xMid | yMid).
void clear() noexcept
Resets this string to be empty.
void stopTimer() noexcept
Stops the timer.
void startTimer(int intervalInMilliseconds) noexcept
Starts the timer and sets the length of interval required.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.