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 Discussion / image resize props

Author
Message
ico2
21
Years of Service
User Offline
Joined: 3rd Jan 2004
Location:
Posted: 4th Sep 2004 06:02
ok, i am rewriting my game (from absloloute scratch) to make it better and to make it so that it functions at different screen resoloutions, 1 of the major problems is the lack of a resize image function, i need to use an image as a background and thus resize it based on the resoloution being used, it is easy to do this with most of the stuff because they are sprites, but using a sprite for a background is going to absoloutely completely and totally murder the frame rate, i need to resize the image so that i can paste it and be done, is there a way to do this without making 3 different sized backgrounds which seeing as i need to use them a lot will take up a lot of space.
medwayman
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: uk
Posted: 4th Sep 2004 20:36
You could resize you background as a sprite then paste it to the screen.

Just curious, why do you want to use different screen resolutions with a 2D game? Well I’m guessing your game is 2D anyway.

Based on Amiga PD game Squigs. Early shots: http://www.custardsoft.pwp.blueyonder.co.uk/images/03.png

ico2
21
Years of Service
User Offline
Joined: 3rd Jan 2004
Location:
Posted: 6th Sep 2004 06:28
i dunno, i just don't want to make it run slow on some pcs and i don't want rubbish graphs, using paste sprite is still going to slow things down is it not?
medwayman
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: uk
Posted: 7th Sep 2004 04:18
Quote: "using paste sprite is still going to slow things down is it not? "


If you do it every pass then yes it will drop the frame rate, but I assume you don’t need to do this, otherwise you would have the same problem with the default background.

It’s no different to loading a bitmap direct to the screen. You resize your background sprite, paste it to bitmap 0, and so long as you don’t clear the screen, there it will remain.

Quote: "and i don't want rubbish graphs"


Surely, if you start resizing images then the quality will deteriorate. if the image is screen size you will lose the aspect ratio and end up with a squashed/stretched image. I don’t claim to be an expert on the subject, but I can’t think of any 2d games that offer multiple screen resolutions. That’s not to say you shouldn’t though

Based on Amiga PD game Squigs. Currently being re-written.

ico2
21
Years of Service
User Offline
Joined: 3rd Jan 2004
Location:
Posted: 8th Sep 2004 03:01
the backs start at 1024x768 so they get reduced not enlarged
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 8th Sep 2004 05:35
(Note: I'm assuming your background is stored as an image)

if it is a 2d game, at the start, create two spare bitmaps, one the original size of the background (1024x768 or whatever) and the second one the size you want the background to be. Load the background into the first, and...

copy bitmap 1,0,0,bitmap width(1),bitmap height(1),2,0,0,bitmap width(2),bitmap height(2)
set current bitmap 2
get image 1,0,0,bitmap width(2),bitmap height(2)
delete bitmap 1
delete bitmap 2

I think that should work.

This may slow the loading time of your program slightly, but voila, you have an image in the right size whenever you want it.

(If I'm wrong, tell me, 'cuz I don't quite understand how your backgrounds are put on the screen...)

[img src=http://blanky.pt-web.net/ddd.gif] >::p
medwayman
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: uk
Posted: 8th Sep 2004 06:47 Edited at: 8th Sep 2004 07:00
It appears that db resizes bitmaps to fit the screen. Try loading your background image without putting a number after the filename.

Load bitmap “whatever.bmp”

The image should fit the screen whatever the size.

EDIT: Blanky, you cant copy a bitmap to a smaller bitmap. If you want to resize the image then you can:

load image "whatever.bmp",1
sprite 1,0,0,1

if screen width()<>1024
size sprite 1,screen width(),screen height()
endif

Based on Amiga PD game Squigs. Currently being re-written.

medwayman
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: uk
Posted: 9th Sep 2004 03:57
Hang on a mo. if you paste a sprite to a bitmap then delete that sprite the image disappears. I assumed that the bitmap would hold the image and the sprite would no longer be needed. Or am I doing something wrong here?

Anyway, loading the bitmap to the screen should solve your problem, but if for some reason you still need images to play with, you can create them on first run of your programme.

This code assumes you have your background in a folder called images and it’s called background1024.



Based on Amiga PD game Squigs. Currently being re-written.

blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 10th Sep 2004 03:22
My code, Custard, was intended so that you could create two temporary bitmaps, copy the big one to the smaller one (which i thought would resize it (damn!)), and then use get image to have it in an image before deleting the now-unneeded bitmaps!

Nothing more,
nothing less...

(P.S. Why can't you copy a bigger to a smaller? I put the sizes specially!)

[img src=http://blanky.pt-web.net/ddd.gif] >::p
medwayman
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: uk
Posted: 10th Sep 2004 06:20
Did I offend you in some way? If I did that was not my intention.

Db just won’t resize the image. It returns a target bitmap too small error.

If you keep the sprite off screen you don’t loose fps, so if you need to update the screen regularly, and don’t want to keep loading the image, you could do something like this



Based on Amiga PD game Squigs. Currently being re-written.

Login to post a reply

Server time is: 2025-05-26 03:16:53
Your offset time is: 2025-05-26 03:16:53