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.

Author
Message
GeneralFOL
16
Years of Service
User Offline
Joined: 29th Mar 2010
Location:
Posted: 20th Nov 2011 22:34
Hi all, i am trying to load and image for example a 512x512 texture, then resize it too for example 256x256, does anyone know of how i can do this in code?.
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 20th Nov 2011 23:00 Edited at: 20th Nov 2011 23:28
How about this? I have not compiled it my self though. (<- I have now, and the first code did not work)



EDIT: I just edited the code so it works

EDIT 2: The screen size has to be larger than the resized image, i.e for 512x512 640x480 will NOT work but 800x600 will.

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
GeneralFOL
16
Years of Service
User Offline
Joined: 29th Mar 2010
Location:
Posted: 21st Nov 2011 00:25
Thanks Cybermind, will give it a try and let you know.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 21st Nov 2011 07:43
The bitmap commands make resizing any image easier without having the main screen be a specific size and it doesn't involve sprites. In the following code snip just change the CREATE BITMAP command to use the size you want instead of SCREEN WIDTH() and SCREEN HEIGHT().



And there's an even easier way with Sven B's Image Kit (using the saved Back1.png above... again change SCREEN WIDTH() and SCREEN HEIGHT() to your desired size):



http://forum.thegamecreators.com/?m=forum_view&t=176270&b=8&p=0#m2100619

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 21st Nov 2011 13:58
The get image approach won't retain any alpha information I think.

There actually are built-in functions in DBP that can accomplish the resizing of an image, but they are hidden away.
Here is an idea of how one could go about using those:



You're probably better off using the Image Kit though, as Grog suggested. Just wanted to point out that it is indeed possible with just the standard dll's.


"Why do programmers get Halloween and Christmas mixed up?"
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Nov 2011 17:55
Quote: "The get image approach won't retain any alpha information I think."


The following works fine for me. Sample source image attached.

GeneralFOL
16
Years of Service
User Offline
Joined: 29th Mar 2010
Location:
Posted: 21st Nov 2011 18:58
Thanks guys for all the help, will experiment with them all and see what works best for my code.

Thanks again for all the help.
Cybermind
Valued Member
23
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 21st Nov 2011 20:41
Will you let us know? Now I am curious

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Nov 2011 08:07
Quote: "The get image approach won't retain any alpha information I think"


The important bit is that line of code in GG's example - SET BITMAP FORMAT 21.

Sven B's Image Kit is essential for image resizing - the quality of the resized images is far superior. With a 50% resize it will look okay, but any other percentage and the quality will degrade significantly.

GeneralFOL
16
Years of Service
User Offline
Joined: 29th Mar 2010
Location:
Posted: 22nd Nov 2011 19:55
Hi all, just a little update, i used the code that cybermind provided and it worked fine, so thanks for that.

However i need to experiment more with the other code provided by you guys, as im thinking the code im using now is great if you know the size of the image being loaded.

But what if im allowing the user to load in there own image and then the code would need to know the size in order to scale it down.

Example the user loads a non standard size of say 400,300 and the code needs to know that size and then shrink it to a 256x256 standard size, or it could be smaller say 100,100.

Dont know if any of this makes sence, but i will keep experimenting with the other code that has been provided and see what i come up with.

Thanks again for all the help.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Nov 2011 01:28
Use the bitmap width(), bitmap height(), image width() and image height() commands.

Login to post a reply

Server time is: 2026-07-10 01:59:18
Your offset time is: 2026-07-10 01:59:18