Leaderboard
Popular Content
Showing content with the highest reputation on 05/04/23 in Posts
-
UInt64 -> TArray<Byte> -> shift bits
Stefan Glienke replied to o815's topic in Algorithms, Data Structures and Class Design
Don't bother and simply use BigInteger from https://github.com/rvelthuis/DelphiBigNumbers (or rather https://github.com/TurboPack/RudysBigNumbers which seems to be the maintained fork) - it most likely has all operations that you need -
Assign KeyDown function to btnClick
programmerdelphi2k replied to Willicious's topic in Delphi IDE and APIs
maybe some like this help you? same that your Edit/Memo-controls is focused, this works! // a easy way... procedure TForm1.Button1Click(Sender: TObject); begin Label1.Caption := 'message button1'; end; procedure TForm1.Button2Click(Sender: TObject); begin Label1.Caption := 'message button2'; end; procedure TForm1.FormCreate(Sender: TObject); begin Form1.KeyPreview := true; // <---- to OnKeyDown,etc... end; procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = vk_return { and other verifications... } then Button1.Click; end; -
No problem in Android Apps. You can do that. You can also do the same in iOS/macOS apps. Just display only Apple "App Store / Mac App Store" link, not the Android one. And to open the link you can use a library like https://github.com/DeveloppeurPascal/librairies/blob/master/u_urlOpen.pas if you don't know how to do it.
-
Change "FadeOut" code to "FadeIn" code
Anders Melander replied to Willicious's topic in Delphi IDE and APIs
That's the ColorModulate function; It "fades" from any color to any color. In your case, you would fade each pixel from black to the color of your new image. Or if you absolutely must have a FadeFromBlack function: // Value = 0: Black // Value = 1: Color function FadeFromBlack(Color: TColor32Entry; Value: Single): TColor32Entry; begin Result.A := Color.A; // Probably 255 Result.R := Round(Color.R * Value); Result.G := Round(Color.G * Value); Result.B := Round(Color.B * Value); end; Apply this to each pixel of your "to" bitmap and draw the resulting bitmap on top of whatever you have on the screen. -
Just set the buttons Default property to true, it will then automatically "click" when the user presses Enter/Return and the active control does not handle the key itself. No code needed...
-
Poor image quality with DrawBitmap when destination is smaller than source
Renate Schaaf replied to XylemFlow's topic in FMX
Well, if one could get one's hands on the DirectDraw-Canvas, and the DirectDraw-RenderingContext, one could write a descendent of FMX-TBitmap which uses the higher-quality setting possible with DirectDraw. I just can't see how, but I'm a newbie. -
Poor image quality with DrawBitmap when destination is smaller than source
Anders Melander replied to XylemFlow's topic in FMX
I think it's just a bug in their implementation. They appear to be AND'ing the pixels instead or OR'ing them. Even the GDI's COLORONCOLOR or STRETCH_DELETESCAN methods, which are just about the fastest methods there are, with the worst quality, would produce a better result. Possibly, but the examples on that page are cooked to show the result you want; They only really demonstrate the effect of a downsample followed by a cubic upsample followed by a linear downsample (you've let the browser shrink the final bitmap). A fair comparison would be to compare the unscaled, downsampled results. What the results would look like when upsampled again with a cubic resampler is not relevant to the downsample quality. Original Downsampled, box filter Downsampled, linear filter Downsampled, cubic filter -
If it's for the purpose of just showing an image with text, I would recommend TImage32, or other libraries. Maybe solutions based on SVG or Skia as well, but TImage32 seems to be the most clean and small solution to just the TImage replacement, with a lot of extras. FMX internally has a lot of Scaling questions, which may drawing on a canvas make it not trivial and different on varous platforms and devices.
-
Assign KeyDown function to btnClick
programmerdelphi2k replied to Willicious's topic in Delphi IDE and APIs
you can call the event as: ComponentXXXX.EventNameXXXX( ... params ) -> like do the Form definitions! Button1.OnClick(Self); -
Brilliant, thank you @programmerdelphi2k! This one worked: procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = vk_return { and other verifications... } then Button1.Click; end; And now, I know how to virtually click buttons, which is incredibly helpful 🙂👍
-
RAD Studio Breakpoints not working
stijnsanders replied to Willicious's topic in Delphi IDE and APIs
I still find it a valid question. I remember this time I had something similar and fixed it by deleting the project's dcu's, to have compile/build generate all new ones. I don't remember how many Delphi versions ago it was though... -
Contributing to projects on GitHub with Subversion
Remy Lebeau replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
+1 for TortoiseGIT -
Integrate with OpenAI's ChatGPT API seamlessly from Delphi. Features Easily access the GPT API from a single class Supports both GPT3 and GPT4 models API key can be read from ChatGPTApiKey environment variable if defined Automatically sanitizes input to minimize errors Ability to define proxy settings Adjust personality response with a precision range of 0-1, from precise to creative Stream responses just like in the ChatGPT web interface Usage Get your API Key: https://platform.openai.com/account/api-keys Define environment variable ChatGPTApiKey and assigned your API key. You may have to reboot your machine for it to take effect. // Basic example showing how to query ChatGPT uses AskChatGPT; var LChat: TAskChatGPT; begin LChat := TAskChatGPT.Create; try // set chat params LChat.Model := GPT3; // use the GPT3 model, or GPT4 for the GPT4 model LChat.Creative := 1; // 0-1, 0 being most percise and 1 being most creative // ask question LChat.Question := 'What is Delphi?' // print question PrintLn('Q: %s', [LChat.Question]); // process and print response if LChat.Process then PrintLn('A: %s', [LChat.Response]); finally LChat.Free; end; end; Media Download https://github.com/tinyBigGAMES/AskChatGPT
-
Poor image quality with DrawBitmap when destination is smaller than source
Renate Schaaf replied to XylemFlow's topic in FMX
Your handcrafted routine isn't *that* slow, just turn on compiler-optimization. As for resampling, I had started to port my parallel bitmap-resampler to fmx, but then I thought, hey, these guys can use DirectDraw, there won't be a demand. Now, seeing how poor the quality is for (supposedly) bilinear rescaling, I have continued working on it. A first version is usable on Windows only for the time being. I just have to add some demos, and I'll probably upload it later today to https://github.com/rmesch/Parallel-Bitmap-Resampler Just in case you might be interested. -
Output from Tree View when using Arrow Keys (as well as Mouse Click)
programmerdelphi2k replied to Willicious's topic in Delphi IDE and APIs
this help you? procedure TForm1.TreeView1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of VK_UP, VK_DOWN: // TreeView1.OnClick(self); Caption := TreeView1.Selected.Text; end; end; I forgot "OnChange" works in mouse/keyboard procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode); begin Caption := Node.Text; end; -
Ask permission to read device notifications on android 13
Dave Nottage replied to Minox's topic in Cross-platform
Are you talking about the demo, or your own app? If your own app, did you follow the instructions in the readme? Either way, please indicate what version of Android you have on your device. -
If you want a very simple way (but not optimized) : set a parent for your image (something linked to a form by a way or an other), add a Text component with characteristics your need, set its parent to the TImage, and do a YourImage.MakeScreenShot to get the new bitmap.