Comments (7)
I fixed it, with 2 threads now works fast and fine!
https://forum.lazarus.freepascal.org/index.php/topic,48085.msg345826.html#msg345826
from bgrabitmap.
Here I tried
https://github.com/bgrabitmap/multithreadedfilter
But I get an exception, that i'm out of memory for creating the thread (like when I resize a lot the form). But it works at least is a start.
I asked in the forum
https://forum.lazarus.freepascal.org/index.php/topic,48085.0.html
from bgrabitmap.
Now I fixed it, but the main form is not very fast or responsive, maybe it can be fixed with another technique.
from bgrabitmap.
I close this since maybe it's good to process images in a background process, is not good for displaying on screen that's one if not the main way to use bgrabitmap.
Is faster using a single thread, at least on my machine. So don't worth the time trying if even the grayscale filter works badly.
from bgrabitmap.
For blur, it is a bit more complicated than grayscale. It cannot be done in-place because the content of pixels influence other pixels. For example, if the first thread changes pixels at the bottom of its target rectangles before the second thread reads those, then the blur result would be different.
Then, the current algorithm for blur would not be adapted, because the source rectangle for pixels is wider than the destination rectangle. For example, if the second thread target area starts at row 100 and the blur radius is 10, then it needs to read pixels from row 90.
So one would need to write a new version of the blur algorithm that can take two rectangles as input, the source and the destination rectangle.
Second difficulty, in order to optimize blur, I've approximated it by a series of box blur one on another:
if radiusX*radiusY >= 100 then
begin
tempDest := ADestination.NewBitmap;
tempDest.SetSize(ADestination.Width,ADestination.Height);
FilterBlurBox(bmp,bounds,radiusX/3.2,radiusY/3.2,tempDest);
FilterBlurBox(tempDest,bounds,radiusX/2.9,radiusY/2.9,ADestination);
FilterBlurBox(ADestination,bounds,radiusX/3.2,radiusY/3.2,tempDest);
FilterBlurBox(tempDest,bounds,radiusX/2.3,radiusY/2.3,ADestination, ACheckShouldStop);
tempDest.Free;
exit;
end;
In this case, each thread need to wait for the others to have completed before going to the next box blur.
from bgrabitmap.
Oh I see, well, it was a good experiment anyways =)
from bgrabitmap.
Yeah threads are interesting. :)
from bgrabitmap.
Related Issues (20)
- Suggestion to improve the documentation of bgrabitmap using pasdoc. HOT 47
- BGRABitmap and FPC 3.2-fixes HOT 5
- compile error on bgrapixel.inc HOT 5
- Maintain the "bit format" of a file between reading and subsequent writing HOT 5
- Error: Duplicate identifier "FResolutionUnit" HOT 4
- Cannot compile package BGRABitmapPack 11.5.8 HOT 4
- Avoid WideString, use UnicodeString HOT 3
- libwebp.pas fails to compile if -Mobjfpc was not used at compilation. HOT 1
- Draw image center/cover no-repeat HOT 3
- Compile error with new visibility check on FPC trunk. HOT 1
- Function 'round' causing problems HOT 17
- libavif.pas fails to compile (mode Delphi) HOT 4
- crash on loading WEBP image on Windows-10 x64 (32bit EXE) when no DLL file is present (it must show nice msg about missing DLL) HOT 12
- -dBGRABITMAP_CORE and Canvas2D HOT 2
- Gradient text and last version 11.6. HOT 3
- Inconsistent kerning of TextSize HOT 1
- Can't close a Form after using draw() onto a TImage.Canvas HOT 3
- Support Inkscape Filters HOT 7
- Add line spacing setting
- Lazarus 3.2 and fpc 3.2.2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bgrabitmap.