[Implemented] Faster Point(x,y)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

[Implemented] Faster Point(x,y)

Post by Polo »

Hi !
I for the moment cannot use the Point() Function from the 2DDrawing module, because it's really really slow, especially when you're using it for getting every colors of big images a lot of time :(
Is it possible to have it faster ?
I know I can use api, but that's not the solution of course :)
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Yes, a cache will be probably implemented to enhance the speed of Point()/Plot().
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Cool, I'ld love to see it ! 8)
S.M.
Enthusiast
Enthusiast
Posts: 118
Joined: Sat Apr 24, 2004 1:11 pm
Contact:

Post by S.M. »

Hi Polo
You could also use the command PointFast() from my userlib E2D: :)
http://hometown.aol.de/moebiusstefan/E2D.zip
regards
Stefan
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

@Fred
Some more about this cache? Bitmaps are in memory, and the cache too.
How will be so useful? I'm really missing something here... :? :wink:
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Here are my tough about this problem:

StartPixelsCache() -> do a getDIB() and put all the pixels in a memory buffer

Point()/Plot() could directly read the value without calling the API which means it will much faster

StopPixelCache() -> copy back the buffer to the image

If you find good name for this 2 functions, don't hesitate to post ;)

Of course, this can be used for all output which could support it.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Sounds like a good idea, for the functions name, well, I don't care what they are ;)
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post by Blade »

Point()/Plot() uses API? I thought you just coded some peek/poke plus colorpace conversoin... ok I see the optimization :)
StartPixelsCache()
Well, perhaps Bitmap instead of Pixel, as the command can be used with more graphical commands (perhaps sprites?) and a bitmaps is an array of pixels... :?:
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

Blade wrote:Point()/Plot() uses API? I thought you just coded some peek/poke plus colorpace conversoin... ok I see the optimization :)
StartPixelsCache()
Well, perhaps Bitmap instead of Pixel, as the command can be used with more graphical commands (perhaps sprites?) and a bitmaps is an array of pixels... :?:
Yes, afaik Point() and Plot() are using the API commands GetPixel_() and SetPixelV_() !?

Bitmaps are stored pixel by pixel RGB or RGBA for example in the memory! So you are right, its a memoryarea or array where the pixel are stored! ;)
(take a look to with a HEXed to an uncompressed BMP and you may see how the image is stored in memory...
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

Fred wrote:Here are my tough about this problem:

StartPixelsCache() -> do a getDIB() and put all the pixels in a memory buffer

Point()/Plot() could directly read the value without calling the API which means it will much faster

StopPixelCache() -> copy back the buffer to the image

If you find good name for this 2 functions, don't hesitate to post ;)

Of course, this can be used for all output which could support it.
This would be awesome. What about ... StartBufferedOutput() and StopBufferedOutput() or something like that? Any better? And would this make all 2d drawing commands draw to memory first? Sounds nice :D
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

Xombie wrote: And would this make all 2d drawing commands draw to memory first? Sounds nice :D
Afaik you cant use API also GDI drawing commands like Ellipse_() to draw this direct to memory/array first! (ofcourse you can draw it to a bitmap that is located somewhere in memory)

So you have to code your own drawing routines to draw direct to memory/arrays first! (this would be a bit hard if you want the same for drawing fonts - but its still possible with some workaround)
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

Maybe something like this would be possible? (i don't know)

Point(x, y [, Mode])
Mode 0 = normal
Mode 1 = fast
I like logic, hence I dislike humans but love computers.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Native bitmaps are in GFX card format, i won't poke/peek directly in it. There are API for this, it's not for nothing :).
User avatar
geoff
Enthusiast
Enthusiast
Posts: 128
Joined: Sun Apr 27, 2003 12:01 am
Location: Cornwall UK
Contact:

Post by geoff »

Yes, you don't know the GFX format, so you have to go via the drivers.

I use the API GetDIBits_() to get the whole image in one API call rather than one call per pixel.

Alternatively you can get one line of the image per API call. This uses less memory but is still very fast.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

geoff wrote:Yes, you don't know the GFX format, so you have to go via the drivers.

I use the API GetDIBits_() to get the whole image in one API call rather than one call per pixel.

Alternatively you can get one line of the image per API call. This uses less memory but is still very fast.
I also use this API, but having it in Purebasic natively and in all platform is better :)
Post Reply