tgstation / rust-g

Rust based libraries for tgstation
MIT License
28 stars 100 forks source link

dmi_strip_metadata leads to removing alpha channel from the icon #135

Closed DTraitor closed 1 year ago

DTraitor commented 1 year ago

dmi_strip_metadata leads to removing alpha channel from the icon Here is the code I used:

/world
    fps = 25
    icon_size = 32
    view = 6

/mob/Login()
    var/icon/test = icon('twitcher.dmi', "preview")
    fcopy(test, "temp.png")
    client << browse_rsc(icon("temp.png"), "first.png")
    call("rust_g", "dmi_strip_metadata")("temp.png")
    сlient << browse_rsc(icon("temp.png"), "second.png")

twitcher.dmi: https://cdn.discordapp.com/attachments/693217263934898190/1111983453760651324/twitcher.dmi

Code result: first.png: first second.png: second

AnturK commented 1 year ago

Yeah, not copying tRNS chunk from the original.

    if let Some(trns_chunk) = reader_info.trns.to_owned(){
        encoder.set_trns(trns_chunk);
    }

Simple fix, under palette copy.