Skip to content
Discussion options

You must be logged in to vote

First, you need to make sure the image is in the rgba8 format (or rgb). After that you need to convert it to a ColorImage.
using the ColorImage you can load the texture in the context.

use image::EncodableLayout;
let color_image = match &image {
      DynamicImage::ImageRgb8(image) => {
          // common case optimization
          egui::ColorImage::from_rgb(
              [image.width() as usize, image.height() as usize],
              image.as_bytes(),
          )
      },
      other => {
          let image = other.to_rgba8();
          egui::ColorImage::from_rgba_unmultiplied(
              [image.width() as usize, image.height() as usize],
              image.as_bytes(),
          )

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@pozix604
Comment options

@sermuns
Comment options

@wangxiaochuTHU
Comment options

Answer selected by Bastl34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants