image-processing icon indicating copy to clipboard operation
image-processing copied to clipboard

How did you make your profile picture?

Open ndavd opened this issue 4 years ago • 7 comments

Hi, I really like how your profile picture looks. Is this how you made it?

ndavd avatar Oct 11 '21 14:10 ndavd

Unfortunately, no, I kind of wish I had, because at least I'd know how to repeat it 😅.

The photo was rendered on this Apple 2 emulator: https://www.scullinsteel.com/apple2/. A friend of mine gave me a .DSK file with it, which I rendered on the emulator and then downloaded. Where did he get the photo? He ran it through this program: http://www.appleoldies.ca/bmp2dhr/. The problem is, the linux download link is broken, and I can't find it in the arch user repository. I think maybe I tried setting it up for windows at some point, but couldn't get it to work. And this friend of mine no longer has it installed either :).

So, uh, if you feel like trying the process out, good luck :D. Let me know how it goes. There's also this website, but I think it produces a somewhat different effect: http://c64.superdefault.com/

AndrewRadev avatar Oct 11 '21 14:10 AndrewRadev

Oh wow didn't expect such an interesting answer! I shall investigate then :D

ndavd avatar Oct 11 '21 15:10 ndavd

Some quick updates... I found this website that talks about that program http://appleoldies.ca/cc65/docs/dhgr/MonochromeDitheringBmp2DHROverview.htm which reads... Some of Bmp2DHR’s color distance program code was adapted from a routine in Joel Yliluoma's arbitrary-palette positional dithering algorithm: http://bisqwit.iki.fi/story/howto/dither/jy/

ndavd avatar Oct 11 '21 15:10 ndavd

Been a while 😄, Just remembered about this and decided to give it another shot...

So, with the help of Web Archive was able to access the Linux downloading page https://web.archive.org/web/20170704165407/http://hoop-la.ca/apple2/appleoldies/bmp2dhr/.

Unfortunately there's no snapshot of the Makefile for Linux, but at least there's the source code. I was able to build the b2d binary but it keeps telling me that my .bmp is in the wrong format... Any change you're still interested on this, lol?

ndavd avatar Jun 18 '24 13:06 ndavd

Hm, it's tricky. I compiled and ran the code in 32-bit mode, I had to include a missing header, and I'm getting the same thing. I added some debug statements for the parsed structures:

% gcc -m32 -o b2d b2d.c && ./b2d ../bmp/lwizard.bmp
Palette 5: tohgr NTSC DHGR Colors
Preview Palette 5: tohgr NTSC DHGR Colors
bfi.bfType:      BM
bfi.bfSize:      0
bfi.bfReserved1: 0
bfi.bfReserved2: 54
bfi.bfOffBits:   2621440
bmi.biSize:          4587520
bmi.biWidth:         3604480
bmi.biHeight:        65536
bmi.biPlanes:        24
bmi.biBitCount:      0
bmi.biCompression:   764149760
bmi.biSizeImage:     247726080
bmi.biXPelsPerMeter: 247726080
bmi.biYPelsPerMeter: 0
bmi.biClrUsed:       0
bmi.biClrImportant:  4278190080
../bmp/lwizard.bmp is in the wrong format!

These numbers are somewhat off, but I can't figure out how. The width and height of this image are 70x55:

../bmp/lwizard.bmp: PC bitmap, Windows 3.x format, 70 x 55 x 24, image size 11660, resolution 3780 x 3780 px/m, cbSize 11714, bits offset 54

The hex code for 70 is 46, if you look for that hex codes in the output of xxd ../bmp/lwizard.bmp | head:

00000000: 424d c22d 0000 0000 0000 3600 0000 2800  BM.-......6...(.
00000010: 0000 4600 0000 3700 0000 0100 1800 0000  ..F...7.........
00000020: 0000 8c2d 0000 c40e 0000 c40e 0000 0000  ...-............
00000030: 0000 0000 0000 00ff ff00 ffff 00ff ff00  ................
00000040: ffff 00ff ff00 ffff 00ff ff00 ffff 00ff  ................
00000050: ff00 ffff 00ff ff00 ffff 00ff ff00 ffff  ................
00000060: 00ff ff00 ffff 00ff ff00 ffff 00ff ff00  ................
00000070: ffff 00ff ff00 ffff 00ff ff00 ffff 00ff  ................
00000080: ff00 ffff 00ff ff00 ffff 00ff ff00 ffff  ................
00000090: 00ff ff00 ffff 00ff ff00 ffff 00ff ff00  ................

There's a number 4600 and if I tweak the long/short types, I can get out 70 and 55, but it's a bit of a mess. Like, I can change the top 3 types of one of the structs from ulong to ushort and:

Palette 5: tohgr NTSC DHGR Colors
Preview Palette 5: tohgr NTSC DHGR Colors
bfi.bfType:      BM
bfi.bfSize:      0
bfi.bfReserved1: 0
bfi.bfReserved2: 54
bfi.bfOffBits:   2621440
bmi.biSize:          0
bmi.biWidth:         70
bmi.biHeight:        0
bmi.biPlanes:        55
bmi.biBitCount:      0
bmi.biCompression:   24
bmi.biSizeImage:     764149760
bmi.biXPelsPerMeter: 247726080
bmi.biYPelsPerMeter: 247726080
bmi.biClrUsed:       0
bmi.biClrImportant:  0

So 70 and 55 are there, but they're just sort of in the wrong places.

C is not exactly my specialty, though I admit it's kind of interesting to try to figure out how to fit the data... Right now, I don't have the time, but I might in a few weeks.

AndrewRadev avatar Jun 20 '24 16:06 AndrewRadev

@ndavd Alright, managed to get it compiling: https://git.sr.ht/~andrewradev/bmp2dhr

The relevant commit is this: https://git.sr.ht/~andrewradev/bmp2dhr/commit/14e0058193274e11d096da55bb9ced05fc0a89d5

The following command-line produces a monochrome image with dithering, the v creates a preview BMP image:

./b2d BMP/PROFILE/austin_7.bmp v mono

Note that the output directory has to be in all-caps, otherwise the program fails. This generates:

Preview In Apple II emulator
austin_7_Preview 2024-07-01-161206_1920x1080_scrot

Annoyingly, the dithering style is not quite the same as my original profile image, but the only thing I can say is that you could experiment with different "dither" and "pallette" command-lines. The program is pretty poorly documented, though, I'll tell you that. Here's one example of a working command-line and its output:

$ ./b2d BMP/PROFILE/austin_7.bmp v hgr D4 P9 
Palette 9: Legacy Win32 Colors
Preview Palette 5: tohgr NTSC DHGR Colors
Color Dithered Output:
Dither = 4 - Atkinson
Preview file BMP/PROFILE/austin_7_Preview.bmp created!
BMP/PROFILE/AUSTIN_7C.BIN created!

So, the P9 is pallette 9, the D4 is for dither 4, and v generates a preview BMP: austin_7_Preview

From this point on, I'd say try to compile it locally and experiment with the options. Let me know if you reach some interesting results :)

AndrewRadev avatar Jul 01 '24 14:07 AndrewRadev

Those are some amazing results, will give it a try today and let you know!

ndavd avatar Jul 02 '24 10:07 ndavd