Skip to content

Added Image::setImageFromMemory and Image::setImageFromRawData - #162

Open
iUltimateLP wants to merge 10 commits into
natinusala:mainfrom
iUltimateLP:main
Open

Added Image::setImageFromMemory and Image::setImageFromRawData#162
iUltimateLP wants to merge 10 commits into
natinusala:mainfrom
iUltimateLP:main

Conversation

@iUltimateLP

Copy link
Copy Markdown

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

Comment thread library/lib/views/image.cpp Outdated
@natinusala

Copy link
Copy Markdown
Owner

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?

@iUltimateLP

Copy link
Copy Markdown
Author

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

Copy link
Copy Markdown
Author

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
iUltimateLP requested a review from natinusala May 6, 2021 14:39
… the first still might be useful for e.g. image files requested from the web
@iUltimateLP iUltimateLP changed the title Added Image::setImageFromMemory Added Image::setImageFromMemory and Image::setImageFromRawData May 6, 2021
@natinusala

Copy link
Copy Markdown
Owner

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 ?

@iUltimateLP

Copy link
Copy Markdown
Author

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

Comment thread demo/dynamic_image.cpp Outdated
Comment thread demo/dynamic_image.cpp Outdated
Comment thread library/include/borealis/views/image.hpp Outdated
Comment thread library/lib/views/image.cpp Outdated
Comment thread demo/dynamic_image.cpp Outdated
Comment thread resources/xml/views/dynamic_image.xml Outdated
Comment thread demo/dynamic_image.cpp
@iUltimateLP
iUltimateLP requested a review from natinusala May 21, 2021 09:22
@natinusala

Copy link
Copy Markdown
Owner

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!

@iUltimateLP

Copy link
Copy Markdown
Author

Sure, here you go :)

@iUltimateLP

Copy link
Copy Markdown
Author

Any update @natinusala? :)

iUltimateLP added a commit to iUltimateLP/NXGallery that referenced this pull request Oct 7, 2021

@EmmmaTech EmmmaTech left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since natinusala is busy, I decided to look at this PR myself. Here is one change you should consider making

Comment thread library/lib/views/image.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants