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.

Dark GDK / DGK C++; Whats faster Pasting with a Sprite or dbPasteImage?

Author
Message
Timidon
19
Years of Service
User Offline
Joined: 26th Jun 2005
Location: Bakersfield, Ca. USA.
Posted: 11th Oct 2010 07:35
Continuing on a train of though, concerning a work around that worked up. What is a faster way of pasting a image to the screen. Is dbPasteImage faster than dbPasteSprite?

What is the consensus?

There are many answers but just one question" ~ Jerilith the Mad
Greg_C
14
Years of Service
User Offline
Joined: 22nd May 2010
Location:
Posted: 11th Oct 2010 10:27
Well I'm not to sure on speed but I think the difference has more to do with what your pasting. These are the discriptions of each one from the documentation:


Quote: "dbPasteSprite
This command will paste the sprite image to the screen, at the specified coordinates. The sprite image pasted to the screen is identical to the current state of the sprite, taking into account scaling, flipping and mirroring. "


Quote: "dbPasteImage
This command will paste the specified image to the screen. Optionally, you can paste images to bitmaps using the dbSetCurrentBitmap command. If the optional transparent flag is set to one, all coloured pixels of RGB(0,0,0) are not drawn. The parameters should be specified using integer values. "


So what I get form this is that if lets say you have an animated sprite if you called dbPasteImage it would paste that entire sprite sheet rather than just pasting the current frame like dbPasteSprite would do. Now I could be completely wrong because I haven't tested it.
N3wton
15
Years of Service
User Offline
Joined: 3rd Jun 2009
Location: Leeds, UK
Posted: 11th Oct 2010 12:46
Quote: "So what I get form this is that if lets say you have an animated sprite if you called dbPasteImage it would paste that entire sprite sheet rather than just pasting the current frame like dbPasteSprite would do. Now I could be completely wrong because I haven't tested it."


it doesn't it pastes the current sprite frame...

as for speed, I would presume sprite is quicker... but I may be wrong.

Yours
N3wton

Timidon
19
Years of Service
User Offline
Joined: 26th Jun 2005
Location: Bakersfield, Ca. USA.
Posted: 11th Oct 2010 16:18
Thanks for you input folks.

There are many answers but just one question" ~ Jerilith the Mad
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 11th Oct 2010 22:02 Edited at: 11th Oct 2010 22:02
I'm away from a compiler now, but you could do something like this to test it



I'll try and test it when I get to a compiler.

http://ref.darkgdk.us/ <- Online DarkGDK Refernece. More content coming soon.
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 12th Oct 2010 02:41
Sorry for double post.

Okay, just got to a compiler, and got some results:


There is not much of a noticeable difference, and using 10,000 iterations is a gross exaggeration of any real world scenario. I doubt that extra 2 ms will make much of a difference.

Here is the source code:


And "image.png," which was used for pasting:


http://ref.darkgdk.us/ <- Online DarkGDK Refernece. More content coming soon.
Timidon
19
Years of Service
User Offline
Joined: 26th Jun 2005
Location: Bakersfield, Ca. USA.
Posted: 12th Oct 2010 03:34 Edited at: 12th Oct 2010 03:36
Wow, now that is science! "CLAP" "CLAP", it Like it. You are man that really came up with a answer with proof. Now why did I not think of that. I bow my coding keyboard to you.

It looks like will be using sprites to scale and stamp my images to the screen, it's still one more step that is involved. So it should not make that big of a difference then.

There are many answers but just one question" ~ Jerilith the Mad
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 12th Oct 2010 03:55
Well, I always use sprites anyways, they tend to be a LOT more flexible for whatever use.

And for testing things, it's quite easy to test the speed of stuff, all you need is a timer. DarkGDK has the "dbTimer()" function, but when you are not using DarkGDK, you have to use the "clock()" function in the <ctime> library.

http://www.cplusplus.com/reference/clibrary/ctime/clock/

Infact, I think that "dbTimer()" is "clock()", just with a different name. Since if you were to do something like this:


Both would read the same number.

http://ref.darkgdk.us/ <- Online DarkGDK Refernece. More content coming soon.
Timidon
19
Years of Service
User Offline
Joined: 26th Jun 2005
Location: Bakersfield, Ca. USA.
Posted: 12th Oct 2010 17:30
I am going to be adding some sprite stamping, just for the flexibility alright. Thanks again and now back to the code.

There are many answers but just one question" ~ Jerilith the Mad

Login to post a reply

Server time is: 2024-11-19 18:22:01
Your offset time is: 2024-11-19 18:22:01