Performance on acces in read/write pixels on canvas under windows and tux lazarus / 39-Graphics ---------------------------------------------------------------------- leneant · 2014-04-24 07:27 Hello, I'm french and i create a image process software. I'm using lazarus 1.2.0 under windows and linux. To translate pix from canvas into my own memory format i read canvas pixels of tbitmap object. For the same pix under windows the process take less than 7 seconds. But under linux the same process takes more than 3 minuts. Linux target compiled. But if i run the windows target compiled under wine the process take less than 7 seconds. Could you help me to resolve the performances diferences between linux and windows ? Web site : http://traitement-d-images-tim.webnode.fr/ Sourceforge : http://sourceforge.net/projects/traitementdimagestim/ Is there some one interests to help me and participate to develop tim with me under linux, windows and mac ? ---------------------------------------------------------------------- Leledumbo · 2014-04-24 16:46 QuoteTo translate pix from canvas into my own memory format i read canvas pixels of tbitmap object.Do you loop over Canvas.Pixels property? If yes, then change your code. It's a damn slow operation. Read "Developing with Graphics" wiki article for an insight. I don't know what makes it faster on windows, logically the difference should be similar (actually, linux should be faster. otherwise, something odd must be happening). ---------------------------------------------------------------------- circular · 2014-04-24 17:02 In your program, you are using bytes to store red/green/blue values. That is what I have done in my library BGRABitmap, so you may not have to change much of your code to use it. See for example this tutorial: http://wiki.freepascal.org/BGRABitmap_tutorial_4 We could also work together to improve LazPaint. ---------------------------------------------------------------------- x2nie · 2014-04-24 17:19 Hi I just visited your site. Wow! it's amazing program. It refine the picture in better appearance. Years ago, I found a software that has similar ability according your "TIM", that named "SmartDeBlur". But, Deblur can be used to restore very-blurred (defocused) picture into understandable by our eyes in unbelievable level of restoration ! I can't modify Deblur, since it was (if I were not wrong) written in Java. Oh yeah, I am glad your code is written in Pascal. I think I am interesting, I will get a try this weekend. --------------------------------------- Now, about the bitmap: I recomended to use TBitmap32 for manipulating bitmap. It has MMX, SSE,SSE2, etc. instructionset support. It always uses 32bit (R,G,B,A), don't know if we can use for your software requirements (R,G,B,L) It has Windows, Linux, Mac (Cocoa & Carbon) supported, via it's backends (QT, GTK, etc) I think, by using TBitmap32 would reduce many time of image-processing time. PS:  Tbitmap32 site:   * http://graphics32.org/wiki/   * http://graphics32.org/news/newsgroups.php?group=graphics32.general  SmartDeblur site:    * http://yuzhikov.com/projects.html    * https://github.com/Y-Vladimir/SmartDeblur ---------------------------------------------------------------------- x2nie · 2014-04-24 17:33 Quote from: Leledumbo on April 24, 2014, 06:46:25 pmQuoteTo translate pix from canvas into my own memory format i read canvas pixels of tbitmap object.Do you loop over Canvas.Pixels property? If yes, then change your code. It's a damn slow operation. I've experienced (knowing) with Tbitmap."PIXEL". In Delphi, we can avoid "damn slow operation" by call TBitmap.Lock / Canvas.Lock which is used to detach the screen update while the pixel updated. This way is usually used in game, while a frame being painted. In the end, we need to call the opposite, which is Unlock to make the bitmap/canvas to back ready to be copied to screen. Linus Trovalds said: "Speaking is easy, show me the code." The code is in "LocasAnt" game code here: * http://www.denysalmaral.com/p/free-downloads.html ---------------------------------------------------------------------- engkin · 2014-04-24 18:33 Quote from: x2nie on April 24, 2014, 07:19:48 pm SmartDeblur site:    * http://yuzhikov.com/projects.html    * https://github.com/Y-Vladimir/SmartDeblur Thanks for sharing this. It's impressive. Quote from: x2nie on April 24, 2014, 07:33:56 pmwe can avoid "damn slow operation" by call TBitmap.Lock / Canvas.Lock which is used to detach the screen update while the pixel updated. I don't think it works faster on other widget sets like GTK2 on Linux. ---------------------------------------------------------------------- leneant · 2014-04-25 06:34 Thanks for all your answers. I will watch them. I think i will be able to push a new version on sourceforge this week-end or next week. Yesterday i looked a page that compare many ways to access pixels of a bitmap. In first i think i will try to make direct access of bitmap memory with rawimage. I had already make that but it ran well under windows but not under linux. Now i understand why. I need to make specif code for windows and linux. On windows pixels are coded on three bytes but on foor under linux. Thats why my previous try didn't run well under linux. After that for new major version i will try others libraries described in yours posts. Thank you for your help. I'll be back soon with my experience with direct acces of bitmap memory. ---------------------------------------------------------------------- leneant · 2014-04-26 19:17 I used direct memory access in place of pixels[x,y] from canvas Its much better and i can use Tim in virtualbox :-) Linux exe : http://sourceforge.net/projects/traitementdimagestim/files /Experimental/TIm/x86/Linux-x86-Tim-V0.65.zip/download sourceforge project : https://sourceforge.net/projects/traitementdimagestim/files/ Web page (in french) : http://traitement-d-images-tim.webnode.fr/ x2nie : if you are interested you can contact me with the e-mail posted on the web site. For all : Thank you for your help.