Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Higher quality Image resize

Author
Message
sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 20th Feb 2011 13:12 Edited at: 20th Feb 2011 13:14
I am trying to resize (mostly reducing) an image/bitmap and the standard `copy bitmap` or pixel resize methods produce jagged results. I'm trying to get something equivalent to the PaintShop Pro `smart` resize. I tried coding a simple reduce taking averages of 2 or 4 pixels but it didn't really work.

What I'm hoping is that there is some `shortcut` that you could copy & paste an image or sprite and get automatic bilinear resizing.

Speed is not really an issue because it's just to display a thumbnail of an image, so even a dbpro routine would be fine. Or even a code snippet of bilinear (or whatever) filtering to get me started.

Cheers
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 20th Feb 2011 14:41
Try downloading GIMP to do it. It's quite good at that sort of thing, and free!

Malevolence: The Sword of Ahkranox
The infinite RPG
http://www.msoa-game.com
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 20th Feb 2011 14:50 Edited at: 20th Feb 2011 14:50
Image Kit has a command IK Resize Image. It supports bilinear filtering for render targets.

Sven B

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 20th Feb 2011 17:25 Edited at: 20th Feb 2011 23:48
@CumQuaT Thanks, but I need to generate them on-the-fly.

@SvenB Thanks that looks good! Can I just do this:



Or do I have to clean up anything after converting it to a render target? (It does work fine as-is, but I don't write anything 3D or gaming so I'm a bit of a novice in this area)

It's a bit excessive to use a 164kb plugin for a single command though, I'm really trying to limit the `bloat` of using lots of plugins. Would the source for the resize algorithm be fairly simple for me to convert to db?


Edit: This is what I have so far, but it doesn't seem to be very effective.

Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 21st Feb 2011 15:40
The snippet you posted should be fine. When converting an image to a render target, the original normal image is deleted automatically and it is replaced by the same image but as a render target.

Sven B

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Feb 2011 18:17
Thanks, it does work in a test progam, but I'm using BlueGUI and you can't place the resulting resized image into a panel gadget the same way as a normal image. I'm guessing `render target` images have a different structure or some other differences.

I'd really like to get the algorithm in my last post working if anyone can spot my mistake.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Feb 2011 21:49
Quote: " if anyone can spot my mistake"


Any clues as to what "mistake" we should be looking for?

[Haven't tried your code yet (busy watching pasta cook right now) so this might be obvious when I do. ]
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 21st Feb 2011 22:04
Couldn't you save the image made by Image Kit to the HD with the SAVE IMAGE command and reload it in BlueGUI?

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 21st Feb 2011 22:43 Edited at: 21st Feb 2011 22:44
Quote: "Any clues as to what "mistake" we should be looking for?"


I was just in the process of creating an image to illustrate and by looking at the comparison I've solved it. I had the distance fraction reversed in the final Y calculation. The snippet below looks like it works (When compared to PSP8 anyway) Just need to convert it to work directly on memblocks now




Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Feb 2011 23:18
Quote: "I've solved it"


Good.

Login to post a reply

Server time is: 2026-07-17 14:00:19
Your offset time is: 2026-07-17 14:00:19