Page 1 of 1

[Implemented] Faster Point(x,y)

Posted: Wed May 25, 2005 12:30 pm
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 :)

Posted: Wed May 25, 2005 12:37 pm
by Fred
Yes, a cache will be probably implemented to enhance the speed of Point()/Plot().

Posted: Wed May 25, 2005 12:44 pm
by Polo
Cool, I'ld love to see it ! 8)

Posted: Wed May 25, 2005 1:28 pm
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

Posted: Wed May 25, 2005 9:22 pm
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:

Posted: Wed May 25, 2005 9:37 pm
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.

Posted: Wed May 25, 2005 9:52 pm
by Polo
Sounds like a good idea, for the functions name, well, I don't care what they are ;)

Posted: Wed May 25, 2005 11:17 pm
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... :?:

Posted: Thu May 26, 2005 12:04 am
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...

Posted: Thu May 26, 2005 12:54 am
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

Posted: Thu May 26, 2005 1:26 am
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)

Posted: Thu May 26, 2005 2:13 am
by Joakim Christiansen
Maybe something like this would be possible? (i don't know)

Point(x, y [, Mode])
Mode 0 = normal
Mode 1 = fast

Posted: Thu May 26, 2005 11:31 am
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 :).

Posted: Sat May 28, 2005 8:45 pm
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.

Posted: Sat May 28, 2005 8:49 pm
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 :)