CPCWiki forum

General Category => Emulators => Topic started by: Devilmarkus on 01:17, 13 November 11

Title: Test: DSK images as PNG, combined with screenshot
Post by: Devilmarkus on 01:17, 13 November 11
I'm actually experimenting with embedding DSK images into a PNG imagefile.
2 ideas were behind this:
- The filesize will be much smaller than a DSK file
- You can add a screenshot and so, when you have your PNG files in a folder with a gallery function, you'll find quickly, what you are looking for.

So how does this work?
- I compress the dsk image
- I write a screenshot (768x544) into a blank image
- I attach the crunched DSK into the PNG (With a R,G,B pixel write method)

When I load this PNG then, I cut the screenshot, convert the encrypted DSK data back to emulator's DSK format...

Example for a possible disk file:
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Devilmarkus on 14:31, 13 November 11
Here you can see how nice it is to load these files:
http://java.cpc-live.com/png_disks/ (http://java.cpc-live.com/png_disks/)
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Gryzor on 14:31, 13 November 11
Oh wow. At first I thought maybe the forum db spewed up an April fool's.

So simple to do, and yet so functional! Wish all the emulators adopted this.
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Devilmarkus on 14:32, 13 November 11
Oh wow. At first I thought maybe the forum db spewed up an April fool's.

So simple to do, and yet so functional! Wish all the emulators adopted this.

Humm no thats no joke ;)
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Devilmarkus on 15:33, 13 November 11
Improved the dsk.png format:
Now the dsk data is absolutely invisible! (But attached to the PNG!)

You can check: Download this file and hex edit it...
Look for the word "PNGDIVIDER" and rest is DSK data!!!
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Devilmarkus on 15:37, 13 November 11
And another: Batman Forever (Complete DISK image attached to screenshot)
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: PhilZeVibe on 16:12, 13 November 11
.
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Devilmarkus on 16:15, 13 November 11
Well I use the extension .dsk.png
So, also, when you have your fileextension hidden, you'll see a png file with extension .dsk ;)
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Devilmarkus on 16:26, 13 November 11
Compare:

Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: PhilZeVibe on 16:34, 13 November 11
.
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Gryzor on 16:40, 13 November 11
Heh... very nice. There will be a few practical problems with this, as in you won't be able to double-click an image and have it open in an emulator. Or maybe, if it's got a dsk extension, do file managers look at the file headers or only at the extension in order to display the thumbnail?

[Edit] Ah, Phi2x mentioned those issues already. But, if you go with the zip alternative then... well, there's no reason to it :D Let's just go for CPCGamesCD (hey, no more updates on this front?)!
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Devilmarkus on 18:01, 13 November 11
Humm I can open it with:
right click on .dsk.png file -> open with: JavaCPC.exe
So, where's the problem here?

Another solution could work as I already write registry entries (when the user wants! The entries are written when the User chooses that!)
Then you would see a rightclick menu entry:
Mount PNG disk image in JavaCPC

(this entry would then also appear on regular PNG files...)

For DSK, CDT and SNA I already added those entries.
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Devilmarkus on 19:46, 13 November 11
Here's a Java-Tool to convert DSK + PNG screenshot to dsk.png disk image.
You can also convert .dsk.png back to DSK. (Works only with the last attached files with invisible data area!!!)

If you don't know, how to start it:
create a .bat file. Content:
java.exe -jar DSK2PNG.jar

(In some cases java.exe is not found on your system, then locate your java.exe file in C:\Programs....\java\(version of your java)\bin and add the "full path + \java.exe")

If someone is seriously interested in this format, contact me and ask how it works ;)
I then will send you my java sources to read those files / store a DSK as PNG file...
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: TotO on 00:30, 14 November 11
Nice work and very interesting feature! (because I never do it :D)
Do you store the compressed DSK file after the picture?
If yes, it-is like an IdTag, and you may add other useful informations.


Keep the 384x272 PNG format, it look better that 768x544 when you browse pictures. :)
dsk.png was a nice idea too...
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Gryzor on 09:30, 14 November 11
I think a mass conversion utility would be much better, even a command-line one... look into a directory and pair dsks and pngs that have the same name?
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Devilmarkus on 10:00, 14 November 11
I updated JavaCPC last night. So simply let it check for Updates.
Load a DSK you like, start it, and when the screen shows the scene you like, press "+" on your numberpad...

Sure it's possible to do a mass conversion. Why not? Will take a look.

The format looks like this:
<png picture><string:PNGDIVIDER><gzipped DSK data>
(!!! The screenshots in this thread use an alternative compression method!!! So herefore you'd need a inflater algorithm! I changed that last night because GZip is more compatible)

When I load it, i cut all incl. the string "PNGDIVIDER" (It's simple to find this string in a byte array). then I load the rest as GZipInputStream.

Example of the structure:
Code: [Select]
00000000h: 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 ; ‰PNG........IHDR
00000010h: 00 00 03 00 00 00 02 20 08 02 00 00 00 BD 38 99 ; ....... .....½8™
/// snip ///
00001ea0h: 00 04 40 00 04 40 00 04 40 00 34 60 87 BF 32 9E ; ..@..@..@.4`‡¿2ž
00001eb0h: D3 75 C6 EF B1 8A 00 00 00 00 49 45 4E 44 AE 42 ; ÓuÆﱊ....IEND®B
00001ec0h: 60 82 50 4E 47 44 49 56 49 44 45 52 1F 8B 08 00 ; `‚PNGDIVIDER.‹..
00001ed0h: 00 00 00 00 00 00 ED D8 CD 8B 24 77 1D C7 F1 5F ; ......íØÍ‹$w.Çñ_
00001ee0h: CF 4C F7 4C CF 43 4F 4F CF 73 4F CF 4C CF 73 0E ; ÏL÷LÏCOOÏsOÏLÏs.
00001ef0h: 09 6A 94 25 87 24 32 EE AE 1A 95 4D 88 AB 04 41 ; .j”%‡$2î®.•Mˆ«.A
/// snip ///
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Bryce on 10:35, 14 November 11
Hmmm, I believe this method has been tried already. Are you sure it has no unexpected side-effects?

Bryce.
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Gryzor on 19:56, 14 November 11
Didn't get it!
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Bryce on 20:44, 14 November 11
Then you need to watch the original Willy Wonkas Chocolate Factory.

Or just compare the scene in the first picture to Markus' sample picture in the first post.
(Jokes aren't funny when you have to explain them).

Bryce.
Title: Re: Test: DSK images as PNG, combined with screenshot
Post by: Gryzor on 21:36, 14 November 11
...or successful :p