Recent

Recent Posts

Pages: [1] 2 3 ... 10
1
Graphics / Re: Drawing grid lines on a transparent image
« Last post by KodeZwerg on Today at 05:42:19 pm »
Here an example:
(I have assigned in designer an image to the TImage control.)
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     CheckBox1: TCheckBox;
  16.     Image1: TImage;
  17.     Panel1: TPanel;
  18.     procedure CheckBox1Change(Sender: TObject);
  19.     procedure FormCreate(Sender: TObject);
  20.   strict private
  21.     FBMP: TBitmap;
  22.   private
  23.   public
  24.  
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. { TForm1 }
  35.  
  36. procedure TForm1.FormCreate(Sender: TObject);
  37. begin
  38.   FBMP := TBitmap.Create;
  39.   FBMP.Assign(Image1.Picture.Bitmap);
  40. end;
  41.  
  42. procedure TForm1.CheckBox1Change(Sender: TObject);
  43. var
  44.   i: Integer;
  45.   GridSize: Integer;
  46.   LBMP: TBitmap;
  47.   X, Y: Integer;
  48. begin
  49.   GridSize := 50;
  50.   LBMP := TBitmap.Create;
  51.   try
  52.     LBMP.PixelFormat := pf32bit;
  53.     LBMP.Width := Image1.ClientRect.Width;
  54.     LBMP.Height := Image1.ClientRect.Height;
  55.     if CheckBox1.Checked then
  56.       begin
  57.         X := 0;
  58.         Y := 0;
  59.         LBMP.Assign(Image1.Picture.Bitmap);
  60.         LBMP.Canvas.Brush.Color := clBlack;
  61.         LBMP.Canvas.Brush.Style := bsSolid;
  62.         for i := 0 to GridSize do
  63.           if ((X + GridSize) < LBMP.Width) then
  64.             begin
  65.               Inc(X, GridSize);
  66.               LBMP.Canvas.FillRect(X, LBMP.Canvas.ClipRect.Top, Succ(X), LBMP.Canvas.ClipRect.Bottom);
  67.             end;
  68.         for i := 0 to GridSize do
  69.           if ((Y + GridSize) < LBMP.Height) then
  70.             begin
  71.               Inc(Y, GridSize);
  72.               LBMP.Canvas.FillRect(LBMP.Canvas.ClipRect.Left, Y, LBMP.Canvas.ClipRect.Right, Succ(Y));
  73.             end;
  74.       end
  75.     else
  76.       LBMP.Assign(FBMP);
  77.     Image1.Picture.Bitmap.Assign(LBMP);
  78.   finally
  79.     LBMP.Free;
  80.   end;
  81. end;
  82.  
  83. end.
If you can follow my code, FBMP keeps the original unmodified version of your image, the checkbox control if there are gridlines drawn over or if it replace current with original.
2
General / Re: Compile/Convert Delphi project to MacOS
« Last post by Martin_fr on Today at 05:29:03 pm »
If you don't use forms....

then you shouldn't need cocoa related code.... Well except, maybe timers, or there are a few things that you could use without GUI that still need code that  knows about GUI...

Some of your units, would use the package LCL or LCLBase (or a package that then uses either of those). Question is, if that unit is used for a reason, or was added by accident.
If the latter, then if you remove all LCL dependencies, and remove the package from the list of required packages, then you don't need interfaces => and your app will become quite a bit smaller.



For the rest... Out of index error => that is something wrong in your code (or code that you called).

Index 0 out of bound => list is empty.

Don't continue, press "break" and it should show you the code that causes the error. Though sometimes you need to open the "stack window" and find the code in the list of callers.

3
General / Re: Lazarus features in a non-graphical environment
« Last post by Lutz Mändle on Today at 05:26:34 pm »
I do not know, how to do an FPC compilation, using these kind of Lazarus features. It is obvious that I cannot have Lazarus running, but then what sort-of makefile or config file is needed to compile Lazarus projects with FPC only.

If your project has a lpi-file try lazbuild, a typical command to compile one of my projects is:

lazbuild -B --no-write-project --ws=nogui <projectname>.lpi

This can be done from a ssh login prompt without a graphical environment.
4
General / what's difference between Variant and TVarRec?
« Last post by egsuh on Today at 05:24:24 pm »
They seem very similar. Well, TVarRec is variant record. But isn't variant variant record?
5
General / Re: Compile/Convert Delphi project to MacOS
« Last post by Joseph on Today at 05:17:16 pm »
So here's what change:

- The project does not use forms.

- Adding Interfaces seems to improve (or at least change the error). Project seems to compile until error1.png (see joined img), and 'continue' leads to error2.png (see joined img).

- No more previous errors on linker

I have a meeting tomorrow with the creator of this project, so maybe I'll have some other info or relevant input from him to add here.
7
General / Re: splitting an image
« Last post by Thaddy on Today at 04:52:43 pm »
LoadFromStream/SaveToStream?
8
:) Hello :)

I would like to share an experiment that I did:
https://poe.com/s/ELl4xkluKjNpEE1h6vuZ

In the example above, the bot translated a Python code to pascal without me asking. I intended to ask to translate but the AI predicted my intentions. I found the above example very impressive.

The above experiment was made with:
https://poe.com/CAI-NEURAL-API

In the case that you prefer ChatGPT, I have it also ready:
https://chat.openai.com/g/g-bqMxEDpIg-neural-api-free-pascal-developer

I have no intention in making money with POE nor ChatGPT. I configured these bots for my own usage. They contain the CAI interfaces so they know how to suggest coding.

:) I wish everyone happy pascal coding :)

Regarding the chatGPT interface version. Is that available as an assistant in the playground? I don't have a PRO account, but use the API through my (still limited) client.

9
General / Re: splitting an image
« Last post by madref on Today at 04:39:31 pm »
@Dzandaa


You use
Code: Pascal  [Select][+][-]
  1.                 Picture:= TBGRABitmap.Create;
  2.                 Picture.LoadFromFile(DOpenPicture.FileName);
  3.  
to load the picture.


But how do I do this from a TImageList
10
Graphics / Re: Drawing grid lines on a transparent image
« Last post by KodeZwerg on Today at 04:30:06 pm »
When needed, why not draw the lines to original image on the fly?
Pages: [1] 2 3 ... 10

TinyPortal © 2005-2018