-
Content Count
2561 -
Joined
-
Last visited
-
Days Won
133
Everything posted by Anders Melander
-
Parallel Resampling of (VCL-) Bitmaps
Anders Melander replied to Renate Schaaf's topic in I made this
Okay, but why? Oh, I think I see what you are doing. Is it correct that... ...gives you the smallest size of a kernel containing all values >= 1/255? -
Parallel Resampling of (VCL-) Bitmaps
Anders Melander replied to Renate Schaaf's topic in I made this
Okay, but why? As you know, my calculation is based on FWHM: and the value you use now is the same as Gimp's but I don't understand the rationale for that calculation. Of course, one can use any radius/sigma factor one chooses since it's kind of an abstract value (for some algorithms) but it makes it a bit difficult to compare blurs if they don't use the same scale. The Gaussian RMS test isn't that important, BTW. AFAIR, it does a blur of a single-pixel vertical line and then compares the horizontal pixel values to the ideal Gaussian curve. If your Sigma/Radius differs from the one I use for the test curve it will show in the RMS. For example, a single pass box filter will have a high RMS. Two passes will produce a lower RMS, and three passes even lower, etc., as the filter approximates closer and closer to the Gaussian. The more important test is the Gaussian signal loss. In that, I sum the blurred pixel values and compare that against the summed Gaussian values. I.e. I compare the integral of the filter and the integral of the ideal curve. In theory, they should both equal 255. In practice, rounding errors make this difficult to test precisely. For example, the sum of the ideal curve is 252 for a radius of 10. Your algorithm has a loss of zero against the theoretical ideal curve (i.e. you have a sum of 255). This test should not be affected by the Sigma/Radius value. FWIW: https://brainder.org/2011/08/20/gaussian-kernels-convert-fwhm-to-sigma/ https://mathworld.wolfram.com/FullWidthatHalfMaximum.html -
I need advice on converting a 500k lines 32bit Delphi 7 application to 64bit
Anders Melander replied to Yaron's topic in General Help
Don't do that; I don't know your code but I would think that very few strings actually need to be AnsiString. And even if your code already supports Unicode there can still be places that assume that SizeOf(Char)=SizeOf(Byte) and SizeOf(PChar^)=SizeOf(PByte^). Also, WideString is not the same as UnicodeString. WideString should generally only be used with COM. https://docwiki.embarcadero.com/RADStudio/Sydney/en/String_Types_(Delphi) -
I need advice on converting a 500k lines 32bit Delphi 7 application to 64bit
Anders Melander replied to Yaron's topic in General Help
And so will the users if he just ships it 🙂 But seriously; There's already lots of good advice here. If I should add anything it would be to make sure that you do all this under version control (re: Git). That relieves some of the pressure of changing something that works into something that might potentially be full of bugs. It also makes it easy to see what you've changed so far. -
Yes, I know you don't need an extra license. My point was that I don't think you even need to run the installer.
-
You'll be using the command line compiler so you can use any account you like; The compiler is just a regular console application. And as far as I remember you don't even need a license. Just copy the files from an existing installation.
-
You missed the point: The +$0001 is not necessary. The first available custom message ID is WM_USER, not WM_USER+1.
-
Then it was a bad example. No, my guess is that it's cargo cult; The +1 is so widespread that most people think that it's the first available value (which it isn't).
-
Chilkat Delphi DLL API - Experiences
Anders Melander replied to msd's topic in Network, Cloud and Web
One of my current clients has been using ChilKat for FTP & SFTP for years and it seems to work fine. The first thing I did in order to work with it was write a set of wrapper classes that hide the ugly DLL API and abstract the FTP and SFTP differences away. I'd have preferred something with source code though, but AFAIK there's nothing for Delphi and the choice had already been made. -
What's wrong with WM_USER + 0 ?
-
Parallel Resampling of (VCL-) Bitmaps
Anders Melander replied to Renate Schaaf's topic in I made this
Pretty nice validation result. Extrapolating from your benchmark result, I'm guessing your CPU is about twice as fast as mine and that my blur would process something like 20,000,000 pix/sec on your system. Can that be right? There's no guarantee that my validation algorithm is correct (I cooked it up myself). You might want to verify that before you start mangling your code. -
Tracking down exception in initialization section ? (RaiseExceptObject)
Anders Melander replied to Eric Grange's topic in RTL and Delphi Object Pascal
The last time I looked, the JCL JDBG functions didn't directly surface the debug data; You can ask the functions to resolve addresses and so on, but you can't get a list of all units, symbols, line numbers, etc. Isn't it correct that you had to modify the JCL source in order to get the JDBG data you needed out of it for your profiler? -
Parallel Resampling of (VCL-) Bitmaps
Anders Melander replied to Renate Schaaf's topic in I made this
A box blur is almost always faster. Almost... -
Parallel Resampling of (VCL-) Bitmaps
Anders Melander replied to Renate Schaaf's topic in I made this
Source or it didn't happen 🙂 -
Parallel Resampling of (VCL-) Bitmaps
Anders Melander replied to Renate Schaaf's topic in I made this
You really do need to handle the alpha channel if you are going to operate on 32-bit bitmaps. Basically, it's the same as what you did for the resampler: Premultiply, blur, unpremultiply. Enable the checkerboard pattern in TImgView32.Background and you should be able to see it. Sure, that would be nice; Go ahead. Just make a version that has the same API as the existing ones: procedure Blur(Bitmap32: TBitmap32; Radius: TFloat); overload; and optionally: procedure Blur(Bitmap32: TBitmap32; Radius: TFloat; const Bounds: TRect); overload; procedure Blur(Bitmap32: TBitmap32; Radius: TFloat; const BlurRegion: TArrayOfFloatPoint); overload; If you start by posting to your own repository I can do the work required to get it integrated into Graphics32. My test bench validates the following: Edge handling Does the "outside" of the bitmap bleed into the blurred bitmap. Basically, I just blur a white bitmap and verify that all pixels are still white. Alpha bleed Does the color of fully transparent pixels bleed into semi-tranparent pixels. Color overflow No R, G, or B values should increase. A minor decrease, when blurring a solid color bitmap, is allowed. Loss/gain due to premultiplication I test the average color loss of blur of a solid color bitmap, with varying alpha. This mostly tests the precision of the premultiplication. Average RGB error and lightness change I blur a gradient and compare the average RGB-, and lightness change. Horizontal and vertical symmetry I blur some horizon and vertical lines and verify that they have been blurred symmetrically. Gaussian error I blur a line and verify that the blurred result corresponds to the Gaussian curve. RMS error and signal loss are validated. Vertical error I blur a vertical line and verify that all rows contain the same color value. Horizontal error I blur a horizontal line and verify that all columns contain the same color value. Uniform RGB I blur a sequence of solid color bitmaps, with increasing R=G=B and verify that the result doesn't contain noise. This usually catches simple over/underflows. The result looks like this: FastBlur (box), Angus Johnson [1024 x 1024, 10] PASS: Edge handling PASS: 100% alpha bleed: 0.00% bleed, 0 errors PASS: Overflows: 0, max swell: 0.00%, 0 bleeds PASS: Alpha: 31, Average loss, RGB: 0.92 %, A: 0.00% PASS: Alpha: 63, Average loss, RGB: 0.52 %, A: 0.00% PASS: Alpha: 95, Average loss, RGB: 0.26 %, A: 0.00% PASS: Alpha: 127, Average loss, RGB: 0.26 %, A: 0.00% PASS: Alpha: 159, Average loss, RGB: 0.13 %, A: 0.00% PASS: Alpha: 191, Average loss, RGB: 0.00 %, A: 0.00% PASS: Alpha: 223, Average loss, RGB: 0.00 %, A: 0.00% PASS: Alpha: 255, Average loss, RGB: 0.00 %, A: 0.00% PASS: Average RGB error: 0.48 % : Lightness change: -0.50 % PASS: Horizontal symmetry error: 0.00 PASS: Vertical symmetry error: 0.00 PASS: Gaussian RMS error: 7.94 FAIL: Gaussian signal loss: 6.67 % PASS: Vertical errors: 0 PASS: Horizontal errors: 0 PASS: Uniform RGB[ 31] errors: 0 ( 0.00 %), noise: 0 PASS: Uniform RGB[ 63] errors: 0 ( 0.00 %), noise: 0 PASS: Uniform RGB[ 95] errors: 0 ( 0.00 %), noise: 0 PASS: Uniform RGB[127] errors: 0 ( 0.00 %), noise: 0 PASS: Uniform RGB[159] errors: 0 ( 0.00 %), noise: 0 PASS: Uniform RGB[191] errors: 0 ( 0.00 %), noise: 0 PASS: Uniform RGB[223] errors: 0 ( 0.00 %), noise: 0 PASS: Uniform RGB[255] errors: 0 ( 0.00 %), noise: 0 In your mailbox in a few days, if you're lucky I'll include the test bench too. By the way, I can really recommend that you profile your implementation with VTune. This is an area that usually benefits greatly from that. -
Setting the drop down width of a Combobox in Delphi
Anders Melander replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
THeY fouND tHe cOdE On ThE InTeRwebS. It muST be ThE beSTESt! -
Parallel Resampling of (VCL-) Bitmaps
Anders Melander replied to Renate Schaaf's topic in I made this
By "FastGaussian" I guess you mean the FastBlur routine? FastBlur is actually a box blur and not a true Gaussian blur. This is just fine for some setups, but not so great for others. Also, performance is, as you've discovered, not the only important metric when comparing blurs. Fidelity can also be important. It completely depends on what the blur is used for. Some algorithms are fast but suffer from signal loss or produce artifacts. Some are precise but slow. And then there are some that do it all well 🙂 The parameters below are [Width, Height, Radius]: Case in point, BoxBlur32 above is consistently the fastest but also has the worst quality and doesn't handle Alpha at all. Use floats and implement it with SSE. That's what I did 🙂 -
Tracking down exception in initialization section ? (RaiseExceptObject)
Anders Melander replied to Eric Grange's topic in RTL and Delphi Object Pascal
It's free for non-commercial use. And yes, it does handle exceptions in the initialization section. -
Tracking down exception in initialization section ? (RaiseExceptObject)
Anders Melander replied to Eric Grange's topic in RTL and Delphi Object Pascal
Have you tried madExcept? -
Library for modifying windows PE files?
Anders Melander replied to Vincent Parrett's topic in General Help
map2pdb has code to read and update the PE header and add a section. You might be able to tweak that into whatever it is you're doing. https://bitbucket.org/anders_melander/map2pdb/src/master/Source/debug.info.pdb.bind.pas -
Load DLL from resource, bypassing a file?
Anders Melander replied to Angus Robertson's topic in Windows API
You are talking about self-modifying code or simply the ability of a process to alter its own page-level protection. While that is an OS feature that is used to implement embedded DLLs it isn't specific to it. Lots of other application techniques use that feature. I thought you meant that embedded DLLs posed a risk to the applications using them. It seems you mean that an application using embedded DLLs potentially poses a risk to the system as a whole. By extension of that argument, you could just as well argue that compiled code is unsafe and that all applications must be distributed as source and compiled by the user. But since you are not going to argue, let's not go there 🙂 -
Load DLL from resource, bypassing a file?
Anders Melander replied to Angus Robertson's topic in Windows API
I fail to see how. Can you give an example? Using an embedded DLL, the application executes code that it itself has supplied and linked. If anything, this should be safer than loading an external DLL from disk and executing code in that. This is not "getting into the system". Everything happens in user mode within the application. -
Load DLL from resource, bypassing a file?
Anders Melander replied to Angus Robertson's topic in Windows API
I can't see how they could prevent it without breaking a lot of applications that are doing similar (but not necessarily the same) things. It's basically just juggling page protection and modifying memory. All done in USER-level. Also, why should it pose a security threat? -
Because the manifest controls the runtime environment where Windows execute your application. If your application doesn't have a manifest (internal or external), then Windows assumes that your application is completely clueless about the environment and gives you one where you can party like it's 1999. Apart from that, you seldom need to use a custom manifest; The one generated by Delphi should be good enough for most uses. Try examining the manifest setting in your project again.
-
It's included in the .res file generated by Delphi so you can examine it with a resource editor.