[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Bug reports
. . -> [Subject]  Weird PNG drawing??

Weird PNG drawing??

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Asmodeusbrooding   (22 posts)  [Biography] bio
Date Wed 30 Aug 2023 11:58 PM (UTC)

Amended on Thu 31 Aug 2023 12:21 AM (UTC) by Asmodeusbrooding

Message
Hey Nick,

I've got some weird behavior here with loading and drawing a png...

You can run this code in immediate if you want...

Any idea what's going on?


-- Create miniwindow
win_id = "myMiniWindow"
WindowCreate(win_id, 0, 0, 100, 100, 1, 1, 0xFFFFFF)

-- Load image into miniwindow
WindowLoadImage(win_id, "building", "worlds\plugins\images\building.png")

-- Get window dimensions
local win_width, win_height = WindowInfo(win_id, 14), WindowInfo(win_id, 15)

-- Draw image to fill the entire window
WindowDrawImage(win_id, "building", 0, 0, win_width, win_height, miniwin.image_stretch)

-- Display the miniwindow
WindowShow(win_id, true)


and the image can be found here
https://imgur.com/F7Dq4X5

Seems odd....

On top of this, every time it draws it changes.. I used it on a map and every single time the map reloaded the image shifted slightly and if you redrew it many times it looked animated.


Is this caused by the png not being 8 bit or 24 bit or something? I converted a bmp to png on another conversion website and the image worked OK. I'd love to learn about why this one didn't work though..
[Go to top] top

Posted by Fiendish   USA  (2,500 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Thu 31 Aug 2023 10:33 AM (UTC)

Amended on Thu 31 Aug 2023 10:35 AM (UTC) by Fiendish

Message
The image is 8 bit grey.

I wonder if either the calls to png_read_png from LoadPng and LoadPngMemory need to also include the PNG_TRANSFORM_GRAY_TO_RGB transform or the final bits per pixel needs to be made depth aware instead of choosing 24/32. The former seems safer.

See e.g.

https://github.com/nickgammon/mushclient/blob/5f1ca253cf6f44b65caeafd9f2ad7a4b87817c8e/Utilities.cpp#L3051-L3057

and

https://github.com/nickgammon/mushclient/blob/5f1ca253cf6f44b65caeafd9f2ad7a4b87817c8e/png/pngread.c#L1191-L1198

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (22,928 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sat 02 Sep 2023 06:52 AM (UTC)
Message
That may well be the problem. If this is just one image try converting it to RGB with Gimp or some other program.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


867 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]