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 / streching an image

Author
Message
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 3rd Jan 2008 23:53
How do you strech an image so it fits the whole screen? and when downloading a bitmap how big does it have to be to fit the screen wothout streching?


P.S.sorry about the bad spelling I forgot how to spell strech

Windows Is better than everything
Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 4th Jan 2008 00:16 Edited at: 5th Jan 2008 01:08
it's spelled stretch, if you don't know a word, just google it

well you can't strech bitmaps useing just dark basic commands (correct me if i'm wrong). so you'll have to load the picture as an image (load image Filename String, Image Number). then make a sprite and place it in the middle of the screen (sprite Sprite Number, X, Y, Image Number, screen width(), screen height()). finally you'll have to scale it to exact the screen size (stretch sprite Sprite Number, Sprite Number, X-Scale Value, Y-Scale Value). The problem is, that it uses the sprite's with/height to do that, but with a bit of math you can fix that:
100+100/screen width()/(screen width()-sprite width(Sprite Number)) should get you the X-Scale Value
this trick should also be resolusion proof

for a picture to fill the screen by defauld, it has to be the same size a the resolution (you can modify the resolution). The defauld resolution is 640*480*16, where 640 is the width, 480 is the height and 16 is the collor depth.

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 4th Jan 2008 00:23
what I mean is streching a picture I'm not going to use it for anything other than a background.

Windows Is better than everything
Sinani201
18
Years of Service
User Offline
Joined: 16th Apr 2007
Location: Aperture Science Enrichment Center
Posted: 4th Jan 2008 01:09 Edited at: 7th Jan 2008 04:58
Quote: "(strech sprite Sprite Number, Sprite Number, X-Scale Value, Y-Scale Value)"


You spelled it wrong too,

Seriously, how do you make the little blue text come up below your message?
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 4th Jan 2008 02:27
never mind i'll just use it as a sprite even though I don't think it's really ment for back grounds

Windows Is better than everything
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Jan 2008 03:18
@Ed222
It's possible to stretch and compress bitmap images using load bitmap and copy bitmap.

Quote: "when downloading a bitmap how big does it have to be to fit the screen wothout streching?"


To clarify a couple of things, a bitmap in this case is a screen on which a picture or an image can be displayed or drawn on. There are 32 of these. Bitmap 0 is the main screen and the others are hidden for drawing out of view. A picture or image is the file or drawing that is displayed or loaded.

I forget what the maximum size a bitmap can be (something like 11000x11000 has to do with bit depth also) anyway, when loading a picture into a bitmap (specifically using LOAD BITMAP) if the bitmap doesn't exist, that is it hasn't been created using CREATE BITMAP, then whatever bitmap the picture is loaded into will take on the size of that picture. If the bitmap already exists (such as in the case of bitmap 0 - the main display view) the picture will inherit the size of the bitmap screen if the picture's size is greater than the screen size. If it is less, it will just fit into the bitmap screen based on the picture's dimensions.

Quote: "How do you strech an image so it fits the whole screen"

Use COPY BITMAP. Say you used the command LOAD BITMAP "ed222.jpg",1 to load a picture into bitmap 1. You can get the size with BITMAP WIDTH(number) and BITMAP HEIGHT(number). Once you know the size, you can copy the whole screen of bitmap 1 (regardless of the size) to the whole screen of bitmap 0 with something like:



Enjoy your day.
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 4th Jan 2008 18:23
@latch
thanks for the help

Windows Is better than everything
Link102
20
Years of Service
User Offline
Joined: 1st Dec 2004
Location: On your head, weeeeee!
Posted: 5th Jan 2008 01:09
Quote: "You spelled it wrong to"

ok, now I feel stupid

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Jan 2008 04:08
Oops, I forgot to change a line of code - I left the testing values in it. The line:


should read:



The actual copied size (for the whole screen) should only be 1 less than the sizes returned by BITMAP WIDTH and BITMAP HEIGHT

Enjoy your day.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 5th Jan 2008 20:20
Quote: "You spelled it wrong to"


You spelled 'too' wrong!

TDK_Man

Login to post a reply

Server time is: 2025-06-06 16:17:05
Your offset time is: 2025-06-06 16:17:05