Setting a ScaledImage

Hi, I’ve just got 6.1.3 and there’s a change to draggable objects.
It has as ScaledImage now, which I guess is for window scaling. Very useful, as I now don’t have to use the component scale factor to get a correct offset, thanks!
My question is:-

How to I set a bitmap to a ScaledImage if it’s a class variable, without having to instantiate it in code, like this:?

i_PointNormalDragScaled = std::make_unique<ScaledImage>(ImageCache::getFromMemory(BinaryData::Point_Normal_Drag_png, (size_t)BinaryData::Point_Normal_Drag_pngSize));


this->startDragging("Normal", &pointNormal, *i_PointNormalDragScaled.get(), false, &off);

I thought it would be the same as Image, but it isn’t.

What’s the actual problem you’re running into? I don’t understand what you mean by “without having to instantiate it” - you’ll have to instantiate a ScaledImage in order to pass it to startDragging.

The constructor of ScaledImage takes an Image, and an optional scale factor that describes how the physical pixels in the image correspond to logical pixels.

If you have a ScaledImage member in your class, you can assign to it, like so:

dragImage = juce::ScaledImage (juce::ImageCache::getFromMemory (imageData, imageSize));

Although, ImageCache keeps the image cached internally, so you might not need to keep the image as a data member at all, and can just pass the image directly to startDragging instead:

  juce::ScaledImage (juce::ImageCache::getFromMemory (imageData, imageSize)),

Thanks. I like to keep Images as part of the Class
I can do

Image something;

But I can’t do

ScaledImage something;

with this…

 something = ImageCache::getFromMemory(...

Never mind, I’ll do it with a cast.