Skip to content

Conversation

@LSinus
Copy link

@LSinus LSinus commented Aug 17, 2025

A simple but effective interface to create a draw image command, allowing custom content to be rendered inside a rectangle.

While working on a personal project with this library, I felt the need to render custom content on the screen—such as a texture stored in a framebuffer—without losing the benefits of the layout system provided by the library. To achieve this, I introduced the mu_draw_image function, which essentially extends mu_draw_rect by accepting a pointer to a framebuffer for the image instead of a solid color.

Alongside this, the mu_ImageCommand was added to store the necessary data, together with the MU_COMMAND_IMAGE entry in the command-type enumeration.

This makes it possible to forward the request to the user-provided renderer, which can then draw the custom content on the screen.
Screenshot 2025-08-17 alle 18 26 30

A simple but effective interface to create draw image command in order
to draw custom content inside a rect
@ccawley2011
Copy link

It might also be useful to add an additional ID parameter to the command so that it can be used to distinguish between different kinds of images without requiring multiple commands.

Comment on lines +478 to +479
rect = intersect_rects(rect, mu_get_clip_rect(ctx));
if (rect.w > 0 && rect.h > 0) {

Choose a reason for hiding this comment

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

This looks like it'll scale the image rather than clipping it. You'll probably want something closer to how mu_draw_text and mu_draw_icon handles clipping.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, maybe it would be better to remove the line 478 in order to specify with rect the exact dimensions of framebuffer

@awschult002
Copy link

there has been a new community fork of this repository. the community is looking to add some new simple features. please feel free to try your PR over there.

https://github.com/microui-community/microui

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