DM Java - Black Crypt remake

Custom dungeons for DMJava
Forum rules
Please read the Forum rules and policies before posting.
User avatar
Igor Poulpupov
Artisan
Posts: 167
Joined: Sun Dec 05, 2010 9:30 pm

Re: DM Java - Black Crypt remake

Post by Igor Poulpupov »

In fact, the problem is: Black Crypt inventory items are 24x24 (lowest-res), or 48x48 (my res), and so on, while DM items are 16x16 in lowest-res, 32x32 in RTC. Thus the interpolation of items gfx in order to get the good size for RTC will never be perfect: half of the item will be resized x2, the other half will keep the same size...
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: DM Java - Black Crypt remake

Post by Gambit37 »

Yes, this will always be an issue when trying to map different sized images to the RTC resolution. There's no way around it really, other than re-drawing things at the right size.

That said, it *is* possible to use a combination of clever scaling and a few photoshop filters to make things look better quality: This usually involves quadrupling the size of your source image from 24x24 to 96x96, then running a Median Cut filter to make the pixels "run together", then resizing back down to 24x24. This doesn't always work, but some images come out OK.
User avatar
Igor Poulpupov
Artisan
Posts: 167
Joined: Sun Dec 05, 2010 9:30 pm

Re: DM Java - Black Crypt remake

Post by Igor Poulpupov »

I now have an automated Matlab (or Octave or Scilab, I guess) program that directly extract the graphics from all the items located in a chest (the biggest container). It makes the extraction of inventory items graphics very fast (7 games screenshots + 20 seconds of processing -> 56 items gfx). The program also changes the background colour from grey (32 32 32) to purple for RTC (255 0 255). And the hard point: it also resizes the resulting item from 48x48 to 32x32, using the nearest neighbour interpolation.

I don't realize exactly the principle of your processing... What does this median cut filter? I've been looking for it on the internet but I don't understand how the things I've found would help in the resize process... I have photoshop, so I'll try to guess it from there.

Edit: no median cut filter in my "Photoshop Elements"... :? Maybe you mean median filter?
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: DM Java - Black Crypt remake

Post by Gambit37 »

Yeah, the median filter, sorry. It's just something I experimented with for getting a little detail back into smaller images when they are increased in size. To be honest It only works on really simple shapes, and is no good on items with nearest-neighbour interpolation -- it's really only suitable when you want soft anti-aliased edges. I shouldn't have mentioned it, as it's basically useless in the case of Black Crypt :-(

Basically, upscaling a small hard edged image to a larger one only works when exactly doubling (or multiples thereof). Anything else is gonna look a bit crappy unless you actually pixel re-draw the problem areas.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: DM Java - Black Crypt remake

Post by Gambit37 »

One thing I forgot: have you looked into HQX? This is a cool algorithm for smoothing out raster images:
http://hiend3d.com/hq2x.html
http://hiend3d.com/hq3x.html
http://hiend3d.com/hq4x.html
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Re: DM Java - Black Crypt remake

Post by Joramun »

Igor Poulpupov wrote:I now have an automated Matlab (or Octave or Scilab, I guess) program that directly extract the graphics from all the items located in a chest (the biggest container). It makes the extraction of inventory items graphics very fast (7 games screenshots + 20 seconds of processing -> 56 items gfx). The program also changes the background colour from grey (32 32 32) to purple for RTC (255 0 255). And the hard point: it also resizes the resulting item from 48x48 to 32x32, using the nearest neighbour interpolation.

I don't realize exactly the principle of your processing... What does this median cut filter? I've been looking for it on the internet but I don't understand how the things I've found would help in the resize process... I have photoshop, so I'll try to guess it from there.

Edit: no median cut filter in my "Photoshop Elements"... :? Maybe you mean median filter?

Don't forget to save the original version of the graphics !
What Is Your Quest ?
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: DM Java - Black Crypt remake

Post by Gambit37 »

Here's an example of how I would process these images, vs. just doing a straight nearest-neighbour resize. Mine on the left, Igor's on the right.
(Note, image doubled in size for preview)

Image

This is the process

1) Crop to 24x24, delete all the background and dark-grey shadow pixels from around the icon and save as a PNG with transparent alpha channel
2) Increase the size of the canvas a little, so that you have empty pixels on all sides of the icon
3) HQX this image
4) Take the new converted image into PhotoShop
5) Layer -> Matting -> Defringe by 1 pixel (This is bit is really important!)
6) Filter -> Noise -> Median at 2 or 3 pixels (don't go too high or you lose too much detail -- you just want to smooth out the obvious pixels a bit and add extra pixels to where there would be curves on the real object.)
7) Resize back down to 32x32 (or 30x30 / 31x31 if you're gonna add a shadow)
8) Add a shadow, save as an alpha-channel PNG.

You may also need to play with sharpness a little once you've resized down. Hope that helps -- not sure if ll those options are available in PhotoShop Elements...

I know this would be a long process, but in my opinion it's worth it. The nearest-neighbour method of going from 24x24 -> 32x32 looks bad because some pixels are doubled and some are not so you end up with odd shapes and detail in the icon. If you look at the hammer on the right above, this is the one from your pack that you shared. It has strange squares in the handle, while if you use my method, it's nice and smooth.

Of course, you may not want the smoother anti-aliased look as it doesn't really match the pixel look of the game, but I think for the icons it works very well. I'm using a similar approach in something I'm building in DSB: the viewport is old school doubled pixels, while the interface and inventory icons are all higher res... :-)
User avatar
Igor Poulpupov
Artisan
Posts: 167
Joined: Sun Dec 05, 2010 9:30 pm

Re: DM Java - Black Crypt remake

Post by Igor Poulpupov »

It looks great indeed.
Yes, the problem in my method is that half of the pixels is doubled and the other half is not.
I'll try your method, and I'll try to understand exactly how it works in details in order to add it in my program, a full automated program would be much faster to use, plus it could be easily employed for other games... I guess the transparent alpha channel will be hard to put in my program, but it's essential if I do not want my item pixels interpolated with the background coulour.
Thanks again Gambit.

Joramun: no problem, this time I saved the original graphics. My first approach was reckless...
User avatar
Igor Poulpupov
Artisan
Posts: 167
Joined: Sun Dec 05, 2010 9:30 pm

Re: DM Java - Black Crypt remake

Post by Igor Poulpupov »

Gambit, if you look more carefully at your image, you'll see unwanted pixels on the edge of the hammer. I think they have been interpolated with the background colour by HQX. Yes, even if it was a transparent background... I have experienced this problem, now it's solved, but under Matlab only...
I'm not that far from the final program (everything is done automatically), I only miss the final resizing (including defringe and median filter). I don't understand the defringe thing, I tested it on Photoshop but I can't see what it does.

My 104x104 image:
Image
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: DM Java - Black Crypt remake

Post by Gambit37 »

The interpolated pixels come from the resizing back down to 32x32 and probably a bit of the sharpening that I did too. They are not "unwanted", that's the softer look I was going for. :-)
The defringe command expands out the coloured pixels to fill in some grey pixels created by HQX (look at the image over a mid-blue background so see them, you can't see them on a transparent background)

Yours is looking great; there's still a few problem jagged areas but these will probably vanish when resized down -- that's the beauty of going larger -> smaller: it hides all manner of imperfections :-)
User avatar
Igor Poulpupov
Artisan
Posts: 167
Joined: Sun Dec 05, 2010 9:30 pm

Re: DM Java - Black Crypt remake

Post by Igor Poulpupov »

Okay, I have my final program now. Here is my result compared to yours and my first result:
Image
Plus the original Black Crypt item:
Image

I still have some problem with items like the (very beautiful) blackjack armor (the one with a black jewel in the center) since there are some grey (34 34 34) parts in the armor that are recognized as background by my program. Same for bracers. The worst is the three heads flail...

Everything is done automatically using Matlab, no defringe and no filtering. My process:
1) Crop to 24x24, make all the background (=grey (34 34 34)) transparent (I keep the shadow pixels)
2) Increase the size of the canvas a little, so that you have empty pixels on all sides of the icon
3) HQX the image
4) Make the "semi-transparent" pixels totally transparent
5) Crop to 96x96 (ie delete the empty pixels on the sides of the icon)
6) Resize back down to 32x32 using nearest neighbour and replace the transparent parts by purple (255 0 255) parts.

Some more images ready for RTC, including problematic bracers:
Image
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: DM Java - Black Crypt remake

Post by Gambit37 »

I would change step 6 and use the bicubic resize. Yes, it creates fuzzy edges but overall the image will look better. When you use nearest neighbour, you're sort of undoing a lot of those earlier stages due to the difference between multiples of 24 vs. multiples of 32. (Yes, I know 96 is 3 x 32, but that's a factor of three which doesn't divide well using nearest neighbour.)
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Re: DM Java - Black Crypt remake

Post by Joramun »

Regarding the bracers, you could try the following at step 1) :

a- For a shadow pixel, look if it has at least 2 or 3 pink neighbours. If yes, set it pink.
b- Repeat a) until all shadow pixel have at most 1 pink neighbour. (this will gradually eat up the shadows)

That way, gray pixels inside the objects wouldn't transform to background (maybe).
I don't know if it will work for the bracers though.
What Is Your Quest ?
User avatar
Igor Poulpupov
Artisan
Posts: 167
Joined: Sun Dec 05, 2010 9:30 pm

Re: DM Java - Black Crypt remake

Post by Igor Poulpupov »

Joramun: I've been thinking about that, I'll try that.
Gambit: yes, only powers of 2 are good for nearest neighbour resizing, but the problem with bicubic will be the interpolation with the background... Well, maybe I can use my 4th step to get rid of the unwanted pixels around the item. I'll try that too.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: DM Java - Black Crypt remake

Post by Gambit37 »

Ah, you may not realise, but you don't need the powerpink background. RTC doesn't need powerpink, it can use PNGs with full alpha channels....
So if you create all your images on transparent, you can resize however you like and you won't need to worry about anything being blended with the powerpink.
User avatar
Igor Poulpupov
Artisan
Posts: 167
Joined: Sun Dec 05, 2010 9:30 pm

Re: DM Java - Black Crypt remake

Post by Igor Poulpupov »

Really? I've never realised that...
Anyway, you can get interpolations with the transparent part I think...
Well, I've done it, here is the result. For each item, on the left: nearest neighbour, on the right: bicubic. I actually prefer the nearest neighbour: it's more "old school", and closer to the original graphics, especially in terms of colour. I don't think the "1 pixel out of 3" thing is problematic according to the results, thanks to HQX I guess.
Image
Original gfx:
Image
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: DM Java - Black Crypt remake

Post by Gambit37 »

Excellent, looks great! I'm glad all the work has paid off :-)
User avatar
Igor Poulpupov
Artisan
Posts: 167
Joined: Sun Dec 05, 2010 9:30 pm

Re: DM Java - Black Crypt remake

Post by Igor Poulpupov »

So am I.

I'm still working on the not background grey thing, I managed to keep the pixels inside an item grey, but for a bow for example... The gray pixels inside the item are also the background.
The program won't be able to process that, so I'll keep both solutions in the program and after the processing, the user will choose which resulting image is the good one according to the item... (even this way, the flail is terrible to process, and there's a staff full of holes that's even worst)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: DM Java - Black Crypt remake

Post by Gambit37 »

Looks like you'll have to break out the virtual pencils to manually fix up the really bad ones :-)
User avatar
PaulH
Ghastly gastropod
Posts: 3763
Joined: Wed Aug 07, 2002 10:27 pm
Location: Level 6

Re: DM Java - Black Crypt remake

Post by PaulH »

I have a package of all the graphics. Somewhere - on an old computer. Well I think I have, pretty sure I have used them before!
User avatar
Igor Poulpupov
Artisan
Posts: 167
Joined: Sun Dec 05, 2010 9:30 pm

Re: DM Java - Black Crypt remake

Post by Igor Poulpupov »

Really??? It would be great if you can find them...

(but I guess Gambit will hate you if you actually have them: he looked for them everywhere years ago :wink: )
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: DM Java - Black Crypt remake

Post by Gambit37 »

PaulH, you've been holding out on us! :shock:
User avatar
PaulH
Ghastly gastropod
Posts: 3763
Joined: Wed Aug 07, 2002 10:27 pm
Location: Level 6

Re: DM Java - Black Crypt remake

Post by PaulH »

I need to dig a very old hard drive out!
User avatar
Igor Poulpupov
Artisan
Posts: 167
Joined: Sun Dec 05, 2010 9:30 pm

Re: DM Java - Black Crypt remake

Post by Igor Poulpupov »

Just to know if it's useful to keep on extracting the graphics from the game, will it be possible for you to find your package, PaulH?
User avatar
PaulH
Ghastly gastropod
Posts: 3763
Joined: Wed Aug 07, 2002 10:27 pm
Location: Level 6

Re: DM Java - Black Crypt remake

Post by PaulH »

I'll have a look but i can't promise anything. I might be mistaken anyway lol.
Post Reply