borealis icon indicating copy to clipboard operation
borealis copied to clipboard

Added Image::setImageFromMemory and Image::setImageFromRawData

Open iUltimateLP opened this issue 3 years ago • 8 comments

Adds support to set the image resource a brls::Image view shows from memory using nanovg's nvgCreateImageMem.

iUltimateLP avatar Apr 29 '21 13:04 iUltimateLP

Hi, thanks for the PR!

This is a duplicate of #159 but I can merge whichever PR is finished first.

Do you think you could add a way to test / showcase this in the demo?

natinusala avatar Apr 30 '21 16:04 natinusala

Ah didn't see the other PR :)

As for a demo case, I'd implement a new view element "DynamicImage" or something which generates a random Bitmap and renders that!

iUltimateLP avatar Apr 30 '21 19:04 iUltimateLP

Had some nasty bugs with memory allocation, which is why I switched from nvgCreateImageMem (which was pretty unnessecary anyway since it needed a whole image "file" in memory rather than just a raw rgba array) to nvgCreateImageRGBA. Also implemented a little example in demo/dynamic_image and views/dynamicImage.xml. If you click on the image, it will populate with a gradient - let me know what you think!

iUltimateLP avatar May 06 '21 14:05 iUltimateLP

This is absolutely not the same, and if I were to choose I would keep the "from mem" instead of "from RGBA" method.

The "from mem" method is used to load JPG / PNG files from memory, and is actually currently used in the sys-clk manager to display game thumbnails. Any homebrew dealing with images on HOS would need it too (homebrew menu, qlaunch replacement, album replacement...).

I understand that it's hard to generate a random PNG in memory, so how about adding both methods and only making an example for thr RGBA one ?

natinusala avatar May 07 '21 16:05 natinusala

See my latest commit, I had the same thought :P

iUltimateLP avatar May 07 '21 16:05 iUltimateLP

This is great! I feel like the example image is a little bit too big and too close to the other images (it's missing some padding).

Could you maybe make it a rectangle, like the "stretched" image example? And add some top padding. Thanks!

natinusala avatar May 21 '21 16:05 natinusala

Sure, here you go :)

iUltimateLP avatar May 26 '21 08:05 iUltimateLP

Any update @natinusala? :)

iUltimateLP avatar Jul 12 '21 10:07 iUltimateLP