Leaderboard
Popular Content
Showing content with the highest reputation on 10/10/23 in Posts
-
Using inline variables inside loops
David Heffernan replied to havrlisan's topic in RTL and Delphi Object Pascal
I think the asker knows this. The question though is how many variables are there for an inline var inside a loop. Is there one variable? Or is the N variables where N is the number of times the loop body executes? That's the question being asked as I understand it. The answer is that there is one variable. Seems like this is the opposite behaviour from C# https://stackoverflow.com/q/271440/505088 Personally I feel like Delphi has a poor design choice here. I'd expect a local variable that is defined inside a scope, to have a lifetime that was that scope. With the C# design you can achieve both possible behaviours by defining the variable inside or outside the loop body. In Delphi you have to resort to putting the body in a separate procedure. The we have C++ which allow capture by value or variable as specified by the programmer in code. That would also give the same flexibility but without requiring extraction to separate procedure. Or am I wrong? I'm basing this on reading and not practical experience so I may have misunderstood. -
Using inline variables inside loops
Dalija Prasnikar replied to havrlisan's topic in RTL and Delphi Object Pascal
This is expected behavior. There is only single address behind inline variable declaration, not multiple ones. Also captured variables are not stored in the stack, but on a heap. Anonymous methods are basically defined as interfaces with a single method - Invoke - implemented by a hidden reference counted class, and captured variables are stored as fields of that class. When an anonymous method is accessed, an instance of that class is constructed behind the scenes, and it is kept alive through reference counting for as long as is required by the anonymous method it wraps. Because you have a loop you will only see the last value in that captured LKey variable because there is only one anonymous method instance created which you are adding to the list again and again with only one captured LKey field. -
A new version is available V1.6.0.166. This version now supports FB5 release candidat 1. Visit our Homepage and download the Trialversion: https://fbm.gksoft.ch
-
TECNativeMap is a 100% Delphi mapping component using neither browser nor javascript. It is available in VCL and FMX for all platforms. Main new features of the last version Google 2DTiles API support Map and routing support from PTV Group Enhanced color filter with dark and bright theme You can download a trial version for Delphi 11
-
Bitmaps2Video for Windows Media Foundation
Renate Schaaf replied to Renate Schaaf's topic in I made this
But you would have to tell the encoder that every frame is a key-frame, otherwise it only stores the differences. But it can be done ... Also, the access to the frames for decoding needs to be sped up. But you could this way create a stream of custom-compressed images. Of course, no other app would be able to use this format. -
Tracking down exception in initialization section ? (RaiseExceptObject)
Uwe Raabe replied to Eric Grange's topic in RTL and Delphi Object Pascal
AFAIK; the initialization order of units follows the order of the ICODE (Initialization Code-Segment) segments in the Detailed map of segments in the map file. -
Tracking down exception in initialization section ? (RaiseExceptObject)
Eric Grange replied to Eric Grange's topic in RTL and Delphi Object Pascal
Ok, in case anyone encounters a similar issue, here is the ghetto method I used to obtain units initialization order. First after the "begin" of the main, program call a procedure like [ complicated approach deleted ] Just use the map file as Uwe Raabe pointed below,to get the order of initialization, the detailed segments section lists the units in order of initialization. -
Bitmaps2Video for Windows Media Foundation
Renate Schaaf replied to Renate Schaaf's topic in I made this
HEIF is a container format like .mp4, as far as I see Windows manages this file format via WICImage only. MFPack contains headers for this, but all that goes a bit over my head. If you want to test HEVC-compression, you can do this via BitmapsToVideoWMF by creating an .mp4-file with just one frame using the procedures below. This is anything but fast, because of the initialization/finalization of Mediafoundation taking a long time. A quick test compresses a .jpg of 2.5 MB taken with my digital camera to an .mp4 of 430 KB. No quality loss visible at first glance. uses VCL.Graphics, uTools, uTransformer, uBitmaps2VideoWMF; procedure EncodeImageToHEVC(const InputFilename, OutputFileName: string); var wic: TWicImage; bm: TBitmap; bme: TBitmapEncoderWMF; begin Assert(ExtractFileExt(OutputFileName) = '.mp4'); wic := TWicImage.Create; try bm := TBitmap.Create; try wic.LoadFromFile(InputFilename); WicToBmp(wic, bm); bme := TBitmapEncoderWMF.Create; try // Make an .mp4 with one frame. // Framerate 1/50 would display it for 50sec bme.Initialize(OutputFileName, bm.Width, bm.Height, 100, 1 / 50, ciH265); bme.AddFrame(bm, false); finally bme.Free; end; finally bm.Free end; finally wic.Free; end; end; procedure DecodeHEVCToBmp(const mp4File: string; const Bmp: TBitmap); var vi: TVideoInfo; begin vi := uTransformer.GetVideoInfo(mp4File); GetFrameBitmap(mp4File, Bmp, vi.VideoHeight, 1); end; -
You may have hard time to find something like that, because IMHO your formatting is not consistent: After then the begin is in the next line, but after else it is not. It probably boils down to having to write your own formatter.
-
Library for modifying windows PE files?
Vincent Parrett replied to Vincent Parrett's topic in General Help
Actually found some wintrust api's are in WinApi.Windows - fooled by code insight again 🙄 I really wish the windows api translations followed the original h files - a WinApi.Wintrust would make it much easier to find. -
Embarcadero made a form from pyscripter (Embarcadero/python4delphiPublic forked from pyscripter/python4delphi) making the pyscripter to be the "main" repository. In theory all changes makde by Embarcadero should sooner or later be added to the PyScripter repository. According to the webinars I watched they work together to improove the library.
-
Using inline variables inside loops
Remy Lebeau replied to havrlisan's topic in RTL and Delphi Object Pascal
You probably nailed it right. It would make sense to have each loop iteration create a separate instance of the anonymous method and let it capture the inline variables that are local to its containing loop body. But as Dalija explained, that is not what happens. Probably a left-over from when anonymous procedures were introduced and inline variables didn't exist yet, so they just captured variables from the top of the containing function. Now inline variables need more stack frame management, and anonymous procedures haven't caught up to that reality yet. -
Clear not only the Fields property but the FieldDefs too. Do this while the dataset is closed. Then you can rebuild your new fielddefs. if FDMemTable1.Active then begin FDMemTable1.Close; FDMemTable1.Fields.Clear; FDMemTable1.FieldDefs.Clear; end; Now it is ready for you to define the new columns. Index etc done the same way, just clear their definitions. Don't forget there are both an Indexes and an IndexDef, both should be cleared. Filter you would just assign the empty string.
-
The corresponding function is Ceil.
-
Embarcadero Toaster - Notification Window Caption in Win10
Patrick PREMARTIN replied to Shavkat PANDA's topic in VCL
Hi For those how haven't seen it, the solution is to call PlatformInitialize on your TNotificationCenter component some times before sending any notification like in FormCreate event. Windows will have time to see the shortcut file linked to the registry key and the notification and so not display the registry key name but the EXE file name instead. This problem is just a simple delay in Windows between creating files and seeing them in other API... If you have previous Delphi releases, without PlatformInitialize method, you can create a shortcut to your program in the user startup menu program folder. It should work.