ui: include desktop icon into binary
This commit is contained in:
parent
7ce77e85af
commit
7e53fc2dd6
1 changed files with 5 additions and 9 deletions
14
src/main.rs
14
src/main.rs
|
@ -12,6 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
use eframe::icon_data::from_png_bytes;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
|
@ -32,7 +34,7 @@ fn real_main() {
|
||||||
use grim::AppConfig;
|
use grim::AppConfig;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use egui::{IconData, pos2};
|
use egui::pos2;
|
||||||
|
|
||||||
let platform = Desktop::default();
|
let platform = Desktop::default();
|
||||||
|
|
||||||
|
@ -54,14 +56,8 @@ fn real_main() {
|
||||||
.with_inner_size([width, height]);
|
.with_inner_size([width, height]);
|
||||||
|
|
||||||
// Setup an icon.
|
// Setup an icon.
|
||||||
if let Ok(image) = image::open("img/icon.png") {
|
if let Ok(icon) = from_png_bytes(include_bytes!("../img/icon.png")) {
|
||||||
let icon = image.to_rgba8();
|
viewport = viewport.with_icon(Arc::new(icon));
|
||||||
let (icon_width, icon_height) = icon.dimensions();
|
|
||||||
viewport = viewport.with_icon(Arc::new(IconData {
|
|
||||||
rgba: icon.into_raw(),
|
|
||||||
width: icon_width,
|
|
||||||
height: icon_height,
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup window position.
|
// Setup window position.
|
||||||
|
|
Loading…
Reference in a new issue