-
Content Count
2771 -
Joined
-
Last visited
-
Days Won
147
Everything posted by Anders Melander
-
Reproduced. I've actually encountered that problem in my own applications but I've never been able to pinpoint the circumstances that surfaced the problem. I'll investigate now.
-
My guess is that you're using the wrong TImgView32.ScaleMode. Make sure TImgView32.ScaleMode=smScale. I've attached a small example that demonstrates how to pan and zoom with TImgView32. imgview32demo.zip
-
Do you sell your software? Are there bugs in it? How do you sleep at night? I guess I don't understand what your point is.
-
Instead of terminating the application in the debugger you can pause it and then examine the call stack to see what the application was doing.
-
Update of Actions in ActionList in a DataModule
Anders Melander replied to shineworld's topic in VCL
Nope. A rewrite of an old, large and complex system is not something that you just do. The history and literature is full of examples why. Remember Netscape, Lotus 123, etc.? -
Update of Actions in ActionList in a DataModule
Anders Melander replied to shineworld's topic in VCL
As you've probably discovered then only difference between having the TActionList on a form and having it on a datamodule is that the shortcuts isn't processed. You can see why in TCustomForm.IsShortCut. As far as I can see you can solve that by simply calling TActionList.IsShortCut from your forms OnShortCut event handler. Apart from that, as @PiedSoftware wrote, the TAction.OnUpdate event only gets called when the action isn't suspended and the associated control(s) becomes visible. For example if you have an action linked to a menu item then the action is only updated when the sub menu that contains the menu item is shown. If you have an action linked to multiple controls then the action is updated if just one of them is visible. A classic goof is to update the actions Visible property in the OnUpdate handler and then wondering why the action isn't updated anymore - it's because the associated control has been hidden and hidden control don't cause the action to update. Also if you use the TActionList.OnUpdate handler be aware that it's called once for each and every action in the list. If you just want an OnUpdate handler that called once for every "cycle" then you can create an action and assign it to the form and use that actions OnUpdate instead. You will have to control the form caption through the action though. -
Yes that seems to be it; TImgView32 adds scrollbars and methods to scroll and center the image.
-
Yeah, I figured that question would be coming To be honest I simply can't remember and the documentation doesn't provide any clues. I'll see if I can figure it out tomorrow unless someone else comes up with the answer.
-
First of all you have to use a scale mode that doesn't control the position of the drawn image. Then it's pretty simple. Save the start cursor position in MouseDown, calculate the delta in MouseMove and scroll the image and end the drag in MouseUp. Here's some code: type TBitmapEditorPreview = class(TWinControl) private FImage: TImgView32; FStartPos: TPoint; FPanning: boolean; procedure ImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer); procedure ImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer); procedure ImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer); public constructor Create(AOwner: TComponent); override; end; constructor TBitmapEditorPreview.Create(AOwner: TComponent); begin inherited Create(AOwner); FImage := TImgView32.Create(Self); FImage.Parent := Self; FImage.Align := alClient; FImage.Height := 200; FImage.SizeGrip := sgNone; FImage.OverSize := 16; FImage.ScaleMode := smScale; FImage.Centered := True; FImage.Bitmap.Delete; FImage.Bitmap.DrawMode := dmBlend; FImage.Bitmap.CombineMode := cmMerge; FImage.OnMouseDown := ImageMouseDown; FImage.OnMouseMove := ImageMouseMove; FImage.OnMouseUp := ImageMouseUp; end; procedure TBitmapEditorPreview.ImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer); begin if (ssLeft in Shift) then begin FStartPos := FImage.ControlToBitmap(Point(X, Y)); FImage.Cursor := crSizeAll; FPanning := True; end; end; procedure TBitmapEditorPreview.ImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer); var NewPos: TPoint; dX, dY: integer; begin if (FPanning) then begin NewPos := FImage.ControlToBitmap(Point(X, Y)); dX := FStartPos.X - NewPos.X; dY := FStartPos.Y - NewPos.Y; if (dX <> 0) or (dY <> 0) then begin FImage.Scroll(dX, dY); FImage.Update; end; Changed; end; end; procedure TBitmapEditorPreview.ImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer; Layer: TCustomLayer); begin if (FPanning) then begin FPanning := False; FImage.Cursor := crDefault; end; end; I've attached the unit I copied the above from. It's part of a larger framework so you will not be able to use it as-is. Here's what it looks like in action (it's the lower pane displaying your avatar): amBitmapEditorPreview.pas
-
The documentation used to be pretty good but much of the newer stuff hasn't been documented (did I mention cowboys ) and many of the examples are more focused on showcasing how awesome graphics32 is instead of explaining how to get stuff done. I even think the current online help is somewhat broken in places. Is there anything I can help with?
-
What's the problem? No but you can assign a TBitmap32 to a TBitmap so this works: var Bitmap: TBitmap32; var Image: TImage; ... Image.Picture.Bitmap.Assign(Bitmap); Note though that if your TBitmap32 uses alpha (i.e. transparency) then you'll need to handle that somehow.
-
I wouldn't bother. It's easy enough for people to open and adjust one of the existing packages. What's lacking is documentation on how to do it. Nobody has all the supported versions of Delphi installed anyway, so we don't really know if all the existing packages are valid. I just did a fast compare of them and I can see that they differ in what they contain and what compiler settings they use so we've already passed the point of maintainability. As I see it, for graphics32, the killing blow was when the team stopped using the newsgroups for communication and moved everything to Github. It fragmented both the developers and the users. Without the newsgroups there is no community and no team. There's no place for the users to ask questions and no place for the team to air ideas or visions and get feedback. Any task that is too big or complex for a single individual is simply not done. On top of that we have a lot of poorly documented code that was contributed by cowboys [*] which are apparently no longer interested in fixing their bugs. This doesn't make it any easier for the remaining devs to keep the project going. *) Cowboy Developer: Rides into town, shooting right and left and then rides out of town leading a mess behind. Yeeeehaw!
-
Remove the "{$define OPTIMIZED}" to disable the assembler. That probably won't work with the 64-bit compiler anyway. The pointers are unavoidable. But like I said, I would use Graphics32 instead. It has a high learning curve but the results are better and the library is maintained. Something like this: procedure Test; var Source: TBitmap32; Target: TBitmap32; Resampler: TKernelResampler; begin Target := TBitmap32.Create; try Source := TBitmap32.Create; try Source.LoadFromFile('foobar.bmp'); // Make new bitmap twice the size. You can also make it smaller. Target.SetSize(Source.Width*2, Source.Height*2); Resampler := TKernelResampler.Create(Source); // Resampler is now owned by TBitmap32 Resampler.Kernel := TLanczosKernel.Create; // Kernel is now owned by resampler // Stretch using kernel resampler Target.Draw(Target.BoundsRect, Source.BoundsRect, Source); finally Source.Free; end; // Do something with target bitmap... finally Target.Free; end; end;
-
I've just merged it and as far as I can see that's your first PR to the graphics32 repository, so I guess you meant that you got ignored at some other repository? It seems graphics32 is de facto without a project lead and I appear to be the only one of the old core team doing anything with it these days so there's not much progress or direction anymore. The fabled 2.0 release was planned almost 10 years ago but these days no one seems interested in making it happen and moving forward.
-
I use Plastic's regular 3-way merge tool with Git but I've never used Plastic SCM itself. You can get your hands on the merge tool by installing a trial of the Plastic SCM client. I don't think Semantic Merge has working support for Delphi syntax. There are some external parsers but AFAIK they don't support the newer versions of neither the Delphi language nor Semantic Merge. Here's one: https://github.com/andremussche/SemanticMergeDelphi
-
I've attached an old library (from 1999) that can do it for you. I believe it's been incorporated in several other libraries over the years. I haven't used it since D5 so you might need to tweak it a bit for newer versions. Apart from that I would probably use Graphics32. resample.pas
-
I worked as the lead developer for seven years at a company that pretty much made it their business to move people from Excel to "something better". https://sigmaestimates.com/
-
Example of wasteful, innefficient string manipulation
Anders Melander replied to Mike Torrettinni's topic in General Help
You test is a synthetic benchmark of metrics you don't understand yeilding results you don't know how to interpret. As usual this is completely pointless. I see you've highlighted the peak working set size but do you even know and understand what a working set is? If you really want to learn about how different memory management challenges can affect you then start by learning about what those problems are. Make an effort. One of the reason why your benchmark isn't doing as bad as you'd expect is probable the lack of randomness in the test. You're repeating the same pattern 100 times. If your allocation were random this would fragment the heap badly but since you're allocating, freeing and then later reallocating the same block sizes again and again, there's good likelihood that the blocks can be reused. -
Yes but the topic isn't "stuff that scale nicely".
-
Not really relevant to the topic.
-
ways to organize related code in a form?
Anders Melander replied to David Schwartz's topic in General Help
A psychoanalyst would have an opinion or two about that statement. I'd say you've integrated your weirdness nicely That's a pretty unnuanced statement. I'd say it has a more narrow meaning than what most people think, The rest of your post made little sense to me. Regarding IQ and "intelligence" I would recommend this book: https://www.amazon.com/Intelligence-Reframed-Howard-Gardner/dp/0465026117 or any of his other books on Multiple Intelligences. -
"natural" compare function for sort
Anders Melander replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
Googling "delphi natural sort" would have gotten you the answer. -
I don't have any knowledge about your exact problem but: You have the source so you should be able to see how and why assigning a popup menu to the control affects the standard menu. Use a TActionList instead of wiring the menu items directly.
-
If it works for you then that's great. Why should I try to convince you otherwise.
-
Yes, exactly like that. Now you just need to convince Embarcadero to integrate it with the IDE. I haven't tried it yet as I wasn't too happy about adding one problem (an external dependency) to fix another one. I'll give it a try now anyway. I guess that should be fixed by the authors. Did you try to make that happen?