Author Topic: So here's a head scratcher...  (Read 6989 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
So here's a head scratcher...
« on: November 04, 2020, 04:42:40 pm »
Step 1: Download the image file below.  (temp.png)

  [ You are not allowed to view this attachment ]  


Step 2: Open it in Paint, or some other external image viewer.  What you'll see is something like the following:

  [ You are not allowed to view this attachment ]  

Step 3: Now, run the following code in QB64:

Code: QB64: [Select]
  1. l = _LOADIMAGE("temp.png", 32)
  2.  

What it should look like is the following:

  [ You are not allowed to view this attachment ]  

Step 4:  Explain to me what the heck QB64 is doing to render all those colorful cursors that Paint and other such programs are failing to do.  This is an image I've saved with the SaveImage library, and I have no idea how the BLEEP it's producing this type of result.  As a QB64 image, it's fine!  (HOW??)  In any other external program, it's not.  Just what the heck is going on here??   

Anyone got any idea at all what's happening so that this *only* seems to work in QB64, and not anywhere else?  What is _LOADIMAGE doing that other programs are failing to do?  Enquiring minds want to know! 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: So here's a head scratcher...
« Reply #1 on: November 04, 2020, 04:52:50 pm »
I'd be willing to bet it is a corrupted image. The external programs are probably trimming out bad data which just so happens to stop after the first cursor. QB64 probably doesn't care or validate the data too well and displays it anyways. I've downloaded corrupted images before by storing the buffer of an image incorrectly and had a similar problem. QB64 couldn't display it but external programs could, but only part of the image as the rest was lost or corrupted.
Shuwatch!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: So here's a head scratcher...
« Reply #2 on: November 04, 2020, 04:55:10 pm »
I'd be willing to bet it is a corrupted image. The external programs are probably trimming out bad data which just so happens to stop after the first cursor. QB64 probably doesn't care or validate the data too well and displays it anyways. I've downloaded corrupted images before by storing the buffer of an image incorrectly and had a similar problem. QB64 couldn't display it but external programs could, but only part of the image as the rest was lost or corrupted.


Running a check on the image, it gets the OK flag, so there's nothing being reported as corrupted with it:

Quote
D:\Temp2>pngcheck temp.png
OK: temp.png (2080x120, 32-bit RGB+alpha, non-interlaced, 99.6%).
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: So here's a head scratcher...
« Reply #3 on: November 04, 2020, 05:01:23 pm »
There's something odd about temp.png look how it's (not) centered in my Thumbnail pictures:
  [ You are not allowed to view this attachment ]  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: So here's a head scratcher...
« Reply #4 on: November 04, 2020, 05:06:29 pm »
There's something odd about temp.png look how it's (not) centered in my Thumbnail pictures:
  [ You are not allowed to view this attachment ]

It's centered.  Windows is only displaying the left arrow, and then all the ones on the right are being covered in white.  The whole image is 2000x120 in size, or so, but only the first fragment on the right is displaying any color for the  preview.   Yet, qb64 loads the whole thing properly, and without any issues, displaying all the little colorful cursors for us. 

I have no idea what the heck is going on here.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: So here's a head scratcher...
« Reply #5 on: November 04, 2020, 05:09:06 pm »
Wait, are you saying the colorful cursors are supposed to be there?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: So here's a head scratcher...
« Reply #6 on: November 04, 2020, 05:35:05 pm »
Wait, are you saying the colorful cursors are supposed to be there?

Yep.  They're there in QB64; just not anywhere else.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: So here's a head scratcher...
« Reply #7 on: November 04, 2020, 06:27:18 pm »
Odd, it it an Animated PNG image? 

My old favorite Paint Shop Pro v4.14 loads it like QB64, but others don't seem to.

- Dav

  [ You are not allowed to view this attachment ]  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: So here's a head scratcher...
« Reply #8 on: November 04, 2020, 06:33:25 pm »
Odd, it it an Animated PNG image? 

My old favorite Paint Shop Pro v4.14 loads it like QB64, but others don't seem to.

- Dav

So now we have two mystery programs where it works (QB64 and Paint Shop Pro) and a dozen more where it doesn’t.  How the heck am I supposed to debug something like this?  Particularly when it works properly in QB64 itself.

@Petr: I just loves you to pieces for finding this one.  No, honestly!  Where’s my chainsaw?  I’m gonna love you to pieces!  ;D
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: So here's a head scratcher...
« Reply #9 on: November 04, 2020, 06:35:44 pm »
Look for the extra ancillary chunks to identify it's an animated png: https://en.wikipedia.org/wiki/APNG

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: So here's a head scratcher...
« Reply #10 on: November 04, 2020, 07:35:02 pm »
I checked it on Internet doubt if this helps but doesn't say corrupt, it is recognized:
  [ You are not allowed to view this attachment ]  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: So here's a head scratcher...
« Reply #11 on: November 04, 2020, 07:47:33 pm »
Look for the extra ancillary chunks to identify it's an animated png: https://en.wikipedia.org/wiki/APNG

It’s not an animated file itself.  It’s basically nothing more than a spritesheet of a cursor.  The only issue is that it looks and works as expected in QB64.  Not so, anywhere else (except in Paint Shop Pro).  And I have absolutely no clue how I accomplished such a feat.

In a way, I’m tempted to just say, “It’s a feature, not a bug.  This is the QB64 Secret Image export option!  Save all your porn in QB64, like this, and your wife and children will never be able to bust you with them!”
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: So here's a head scratcher...
« Reply #12 on: November 04, 2020, 08:17:39 pm »
I think there is multiple things going on here, I copy and pasted the image into my graphics software and saved it as a PNG and this is what I get when I open it in QB64.
« Last Edit: November 04, 2020, 08:21:29 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: So here's a head scratcher...
« Reply #13 on: November 04, 2020, 10:12:38 pm »
@ Steve

Please advise all the steps you took to obtain your "temp.png" - I see the lollipop cursors as you indicated on my computer.

I have been experimenting (for something else altogether) with an image that was converted using MS PAINT from 32bit to 256 color (.bmp). In the 256 color .bmp file (I know you are referring to a .png) - in the header - after the first 56 bytes - the 1024 byte (=256 colors x 4  bytes) color palette look up table is different from the same 1024 bytes that define my HP display. SO sometimes my image (256 colors) is really messed up (in various program environments) - at present I conclude that "I" must take extra programming precautions of defining what color palette look-up table (256 colors) to use and on which hardware configuration etc.

When I converted (using MS PAINT) your temp.png to a 256 color .bmp file - the header shows the 1024 byte color palette as all chr$(&h00) - (? .png always only works with 32 bit color).

I do not see your lollipop cursors in anything else than screen 0.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: So here's a head scratcher...
« Reply #14 on: November 05, 2020, 12:37:35 pm »
Quote
I just loves you to pieces for finding this one.  No, honestly!  Where’s my chainsaw?  I’m gonna love you to pieces!  ;D

First wait a while, I'm just saving the porn in hidden png format :)

Can't it be related to the fact that the source image is rendered using XOR? See cursors.bm, line 502:

         IF s $ = "1" THEN clr = 15 XOR background ELSE clr = 0 XOR background
         PSET (X, Y), clr

But as i wrote, image, which is returned as output for save seems always right. Maybe - try image, which is in program output for saving transport to _CLIPBOARDIMAGE and then insert it to windows paint, if is displayed correctly, then is really bug in PNG record.