![](https://en.delphipraxis.net/uploads/set_resources_2/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
![](https://en.delphipraxis.net/uploads/monthly_2023_08/K_member_12097.png)
Kas Ob.
Members-
Content Count
472 -
Joined
-
Last visited
-
Days Won
8
Everything posted by Kas Ob.
-
Locking an Object
Kas Ob. replied to fastbike's topic in Algorithms, Data Structures and Class Design
Remove all an be done in few ways, the easiest and simplest one is to centralize the access to that object and don't access it directly, use a getter, that getter can be function in singleton or global one, or just a property with getter, this getter will have CriticalSection instead of TMonitor, i just hate TMonitor, it is up to you after all, both will do fine. In that getter the locked section will active only if the field or the object is assigned meaning it will not cause locking once it is created, but if it is not yet assigned, the lock will be holding all threads except one, the creator, once it created and assigned the new callers will not enter locked section, and the waiting ones will be released, but the first check in the locked section will be to see if the object is assigned and created then exit. Just make sure the creating of that object doesn't fail or wait indefinitely. Something like this , more or less function TForm10.GetMyObject: TMyObject; var TempMyObject: TMyObject; begin Result := FMyObject; if Assigned(Result) then Exit; FCriticalSection.Enter; try Result := FMyObject; if Assigned(Result) then Exit; // Create MyObject in TempMyObject , DON'T CREATE FMyObject directly FMyObject := TempMyObject; Result := FMyObject; finally FCriticalSection.Release; end; end; -
fgxnative FGX Native - crossplatform mobile native development
Kas Ob. replied to Yaroslav Brovin's topic in Delphi Third-Party
Thank you ! I am in Ukraine and using the biggest ISP here, but didn't notice and didn't expect changing the language will change prices without changing the items listing themselves (names and prices). -
fgxnative FGX Native - crossplatform mobile native development
Kas Ob. replied to Yaroslav Brovin's topic in Delphi Third-Party
Clicking from here https://fgx-native.com/ru/buy.html also redirect this link to the English one https://forum.fgx-native.com/store/product/1-подписка-на-3-месяца-только-для-рф-и-снг/ -
fgxnative FGX Native - crossplatform mobile native development
Kas Ob. replied to Yaroslav Brovin's topic in Delphi Third-Party
Clicked on that link, here what i see One year for CIS is higher than the rest of the world with the discount. -
GTX SpeedStar F1, code name "Dawn", will make great name. As for the patches, numbers are something from different millennia, better something like AfterDawn or Breakfast, BroLaunch, "MorningCoffee The First of its Name"...
-
fgxnative FGX Native - crossplatform mobile native development
Kas Ob. replied to Yaroslav Brovin's topic in Delphi Third-Party
I can't reach a page with such prices from Ukraine ? -
Do local variables have a cost?
Kas Ob. replied to Nigel Thomas's topic in Algorithms, Data Structures and Class Design
Hard to tell, it depends on many things and the context around it. May be, again no way to tell. I suggest to prefer the readability always, when the efficiency is needed only then you have to test and benchmark different code/algorithms/approaches... , you can profile the code and make sure that there is wasted speed, or even better is to look at the generated assembly, but this is not everyone cup of tea. -
Why does Delphi 12 marginally bloat EXE file size compared to 11.1?
Kas Ob. replied to PaulM117's topic in RTL and Delphi Object Pascal
@Stefan Glienke Right on point there. I want to add one thing about inc/dec vs add/sub 1, they are not faster nor slower, but there is side effect which might sometimes yield a difference and speed boost, the effect is from the competition between two CPU enhancement Out-of-Order-Execution and Speculative Execution, older CPUs have OoOE mostly and little of SE, through generations CPUs are depending on SE more as it enhance and gain more than OoOE, the thing is both share in part (or all i have no idea) of the OoOE window, which is a buffer that handle the Re-Order buffer ROB also, while SE has an extra window/buffer to handle all branches/variations of executions, here these branches are not only branching form jumps only but from calculations, like adc the result might be two variants and that depend on the carry C flag, and this is the real difference, while as you know inc/dec change C flag, add/sub 1 will not, the difference is inc/dec will save bytes to fit in OoOE to execute more instruction, while SE will branching the whole block of following instruction due the change of C flag, thus shorten its overall can-be-executed. This effect can be witness if C flag is used in a loop to detect or checked, also can be observed when the loop is bigger than the OoOE window, on my SandyBridge that window size is 168 byte, and SE is not playing any role, on more modern CPU that windows is more than 224 bytes, i couldn't find a table or a list of comparison for many CPUs, but observed this on big loops running on modern XEONs, against the test on my SandyBridge where the loop is big more than ~180 byte of instructions and add/sub where faster by ~%5, and on mine add/sub was slower by ~%1. -
Memory leak with anonymous methods.
Kas Ob. replied to pyscripter's topic in RTL and Delphi Object Pascal
No leak on XE8 and Seattle.- 4 replies
-
- anonymousmethods
- threads
-
(and 1 more)
Tagged with:
-
I have to point that they are not installed by default for good reason, so i recommend to install them only on project bases instead of keep them installed and laoded on the IDE. These components will bring huge overhead from Windows GUI shell, background threads, hooks, etc... they will affect the IDE stability and responsiveness and bring Windows Defender hooks in your IDE, so nice to have them on specific projects but not all the time loaded with the IDE, you can install them and disable them from loading and enable them only when needed in a project.
-
class EOleSysError with message 'Class not registered'
Kas Ob. replied to SneakyPeaky99's topic in Delphi IDE and APIs
Here is a better example than the above, you can see the implementation in full. -
class EOleSysError with message 'Class not registered'
Kas Ob. replied to SneakyPeaky99's topic in Delphi IDE and APIs
Drop the DLLs one by one in EXE Explorer, then in Resource tab check the Registry also you might find the TypeLib there, And because you have a working version use Jon method above is more concise for finding the working DLL than searching the DLLs for the needed class. -
class EOleSysError with message 'Class not registered'
Kas Ob. replied to SneakyPeaky99's topic in Delphi IDE and APIs
Also try the super duper EXE Explorer from Mitec https://mitec.cz/exe.html you should be able to find your library and class in a DLL. -
class EOleSysError with message 'Class not registered'
Kas Ob. replied to SneakyPeaky99's topic in Delphi IDE and APIs
Then try to register them all, no harm from that. -
class EOleSysError with message 'Class not registered'
Kas Ob. replied to SneakyPeaky99's topic in Delphi IDE and APIs
Did you register that DLL with that specific class ? You listed what you did but did not mention if it is registered for fact, loading a DLL doesn't mean the COM component is registered or known for the system. as for search the internet, you should search for the error message first then try the GUID for that specific class, try "windows register com dll class" or something else and find how hard complex it is to register one. -
Prevent Multiple Instance from running at the same time
Kas Ob. replied to new_x's topic in Windows API
Your code is closing the handle, so how the next instance will get ERROR_ALREADY_EXISTS ?! Redesign that. -
Suggestion of naming convention for enumerators
Kas Ob. replied to JohnLM's topic in Algorithms, Data Structures and Class Design
I agree with Peter, but on other hand there a scenario where i did similar thing, i needed to serialize many data in compact structure on disk, big data and they needed to be loaded and saved fast, so yes, sometimes it is needed, where the data will have first byte as the index of the encoder then the 4 bytes for the length then the data itself, even if this not case, as process of experimenting and learning it is good to do it once at least in life. now to the OP question Here i have few thing to point 1) SetLength is useless. 2) both function should have their parameters as const, both String and TBytes are managed types, it is better to tell the compiler that they are constant. 3) you are building your own library which is good thing in the long run, here i suggest to use distinctive functions for your own, prefix their names with something you will use and recognize, something like JmStr2Bytes, JmBytes2Str do this for all your code and you will have good time with autocomplete. 4) refrain if possible from using underscore _ , it is ugly, and later you will start to hate it, also the lowercase is something personal but why not give Camel a chance and see if it will click with you. Really i am not sure about the question, is it about the functions/procedures names, the enums or both? but .... my opinion is one for all use prefixes, Jm Jl jL Jm Lm Ml ML mL Mj , just pick any two letters, because it is nice and almost never conflict with other libraries you will use. -
I would suggest logarithmic graph for such data, give them a chance or at least research them.
-
-
Thank you !, and as you asked for, it still refuse to compile on XE8 or Seattle, the problem is with this part, so i worked around to make it work at minimum. Well, you missed my point of test, in my opinion when testing for artefacts or ringing or color bleeding should start at the simplest and smallest details, your TextAndLines doesn't follow my test, my lines were at 1 pixel every 5, i wanted to see text and their readability in this one, and it did in fact showed me a lot. So here my Lines and text procedure LinesAndTextBitmap(const bmp: TBitmap; w: integer); var X, Y: Integer; begin bmp.PixelFormat := pf32bit; bmp.SetSize(w,w); bmp.Canvas.Font.Size := 24; bmp.Canvas.Font.Color := clRed; bmp.Canvas.TextOut(10, 10, 'Test'); bmp.Canvas.Font.Size := 48; bmp.Canvas.Font.Color := clGreen; bmp.Canvas.TextOut(50, 50, 'Test'); bmp.Canvas.Font.Size := 32; bmp.Canvas.Font.Color := clBlue; bmp.Canvas.TextOut(150, 150, 'Test'); X := 5; while X < w do begin bmp.Canvas.MoveTo(X, 5); bmp.Canvas.LineTo(X, bmp.Height - 5); Inc(X, 5); end; Y := 5; while Y < w do begin bmp.Canvas.MoveTo(5, Y); bmp.Canvas.LineTo(bmp.Width - 5, Y); Inc(Y, 5); end; end; You can adjust the 5 also to make it target the little details, there is the devil. Now to the result and you gonna love it As for speed, it is waayyyy slow and very eligible for optimization, a lot of tweaking and definitely assembly will give it a great push, so i will find time and more important than time, wait until my OCD kick and will dig into it, heck i have many of those functions already somewhere written in fast SIMD, no promises though, just i have too many dark days, unlike your The long Dark, i am in a dark place for many years now, coding sometimes helps to see some light in a tunnel. If you would please, just skip using anonymous methods, this will push the compatibility many Delphi versions back, as for short code, well not worth it for open source and great library. Also as you already did it and got it, why not add all these mentioned filters (in Wikipedia and the ImageMagick links) it is merely copy and paste, right ?, so you will have a filter like Adobe and What every the hell is Paint Net, and so fourth, cost nothing performance like.
-
Use of dynamic control names
Kas Ob. replied to Bart Verbakel's topic in Algorithms, Data Structures and Class Design
I do use lists, i create a list lets, say i want a bunch of controls to be enabled or disabled when a specific value is right/wrong in an edit, register these controls once and use helper function or any other method you like, to enable or disable them, lists are great for grouping. you can hide and show also. -
The missed image from above
-
Dear, you already did all the right things and implemented contributors, i think you are overthinking it, your implementation is great and you are missing just few things to point you right, all these papers are talking about the weight of the neighbors and reduce them to specific formulas represented mathematically, in this case like here https://en.wikipedia.org/wiki/Mitchell–Netravali_filters , P(d) is referenced by P0, P1, P2, P3 the points in 4 direction from p the point you are calculating, while k(x) is a function calculating the weight, which you are already implemented and using with Lanczos, this implementation is almost universal for all filters as it is the best. now re-read these links, with that in mind and you don't need any source as reference, specially you are going to like this but it is not so clear as and Now you can use the same filter to generate blur and antialiasing or force ringing (halo's and ripple), and can't remember what was the blocking . I browsed your code in "View file" in WinRar , i saw MakeContributors and AntiNLanczos and i confident you can just duplicate AntiNLanczos for all the above in the table with B and C or replace them with the calculated value like mine for faster calculation, while MakeContributors most likely doesn't need any change or a may be a little, i am sure you can solve this as it is way easier than how it sound and look. In AntiNLanczos const sqrt3 = 1.7320508075688; b = -27 * sqrt3 / 2 / Pi; d = -1.4 * 0.8933976645E-1; e = 1.0 * 0.1650337606E-1; a = 0.5 - e - d; function AntiNLanczos(x: double): double; var s: integer; begin s := 1; if x < 0 then begin x := -x; s := -1; end; if x < 1 / 3 then Result := (3 + (-162 + 3 / 2 * b + 270 * a + (648 - 9 * b - 1215 * a + (-729 + 27 / 2 * b + 1458 * a) * x) * x) * sqr(x)) * x else if x < 2 / 3 then Result := 1 / 2 * b - 31 * d + a + (-16 / 3 * b + 360 * d + (177 / 8 * b - 1620 * d + (-357 / 8 * b + 3510 * d + (351 / 8 * b - 3645 * d + (-135 / 8 * b + 1458 * d) * x) * x) * x) * x) * x else if x < 1 then Result := -3 / 2 * b - 512 * e + a + d + (9 * b + 3240 * e + (-171 / 8 * b - 8100 * e + (201 / 8 * b + 9990 * e + (-117 / 8 * b - 6075 * e + (27 / 8 * b + 1458 * e) * x) * x) * x) * x) * x else Result := 0.5; Result := s * Result; end; You need these constants a, b, d and e, with Mitchell–Netravali filters you will need only B and C, result is the weigth (w) and x is param , simple like that, only the difference is you are scaling first to do the clamping with shr 22 later , you can drop it or keep it, just adjust the values accordingly. and good luck, waiting to see your result images, as your sample and demos also not working on older Delphi, and please don't waste your time on compatibility now, i will nag you for that later.
-
There is this, irrelevant to the above pT.rgbBlue := Min((max(Total.b, 0) + $1FFFFF) shr 22, 255); pT.rgbGreen := Min((max(Total.g, 0) + $1FFFFF) shr 22, 255); pT.rgbRed := Min((max(Total.r, 0) + $1FFFFF) shr 22, 255); pT.rgbReserved := Min((max(Total.a, 0) + $1FFFFF) shr 22, 255); That is easier to read and understand as simple clamping, but Min and Max are not inlined functions and will waste hell of time just jumping and retunting for simple IF, i suggest to get rid of them with either inlined if possible or just old fashion IF's, these in assembly will be few instructions without any jumping, and in SIMD will be will be one pass for the four colors, but that for later talk.
-
Yet, you didn't mention how the import happen, here an imaginary scenario that will generate that behavior (more or less), if your application grabbing these imported data from internet and using event based network, then the data will come as message and will interfere with other messages, causing a growing delay, this will accumulate till the message queue is full or just the delay getting greater for the OS to detect it right away but after a while the respond from the application the OS decide it is frozen. as a solution in all cases switch to background operation, and don't use Application.ProcessMessage, it will save you great headache later and most likely should be removee it eventually.