[GFX] Translate PHP code to Pascal lazarus / 39-Graphics ---------------------------------------------------------------------- Cobaldblue · 2024-01-26 16:53 Hi, I was given the honorable task of transforming a PHP script into a Pascal program. Unfortunately, I have never worked with graphics functions in Pascal. Therefore I hope that you can help me. I already have some practice developing Windows programs in Pascal / Delphi. However, these were mostly database applications or tools for Windows.  :'( I'm looking for a way to use the following PHP functions in Pascal. Here we go: - Imagecreatetruecolor((($max_x+1)*2048),(($max_y+1)*2048)); //-> Create a new true color image (X,Y) - Imagecolorallocate($newpicture,255,255,200); // -> Allocate a color for an image - ImageCreateFromJPEG // -> Create a new image from file or URL - Imagecopy($newpicture,$serverpicture,($x*2048),($y*2048),0,0,2048,20 48); // -> Copy part of an image - Imagejpeg($newpicture,$savename.'.jpg',100); // -> Output image to browser or file (save image!) Thats it! I've been sitting here at a loss for a while now because I just can't find a solution. ---------------------------------------------------------------------- marcov · 2024-01-26 17:21 Please specify in detail what those functions do?!?!? ---------------------------------------------------------------------- Cobaldblue · 2024-01-26 19:02 Quote from: marcov on January 26, 2024, 06:21:01 pmPlease specify in detail what those functions do?!?!? I have expanded my post with a link to the respective PHP command and added a short description of the command below. I hope this helps... ---------------------------------------------------------------------- KodeZwerg · 2024-01-26 19:10 Its better to explain your task than show what other languages do. Is it correct that you want to load a JPEG image from file and copy part of it as a new JPEG image and save that to file? ---------------------------------------------------------------------- KodeZwerg · 2024-01-26 20:49 If my above statement was correct, heres a method that does do that, take care, it does not check for anything, it just work. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function ExtractJPEG(const AInput, AOutput: string; const AX, AY, AWidth, AHeight: Integer): Boolean;var  LSource,  LDestination: TJPEGImage;  LRect: TRect;begin  Result := False;// add filecheck here to continue or not  LSource := TJPEGImage.Create;  try    LSource.LoadFromFile(AInput);    LDestination := TJPEGImage.Create;  try// add range checks here if given values are really inside source    LRect := Rect(AX, AY, AX + AWidth, AY + AHeight);      LDestination.SetSize(AWidth, AHeight);      LDestination.Canvas.CopyRect(Rect(0, 0, AWidth, AHeight), LSource.Canvas, LRect);      LDestination.SaveToFile(AOutput);// add check here if file was written      Result := True;    finally      LDestination.Free;    end;  finally    LSource.Free;  end;end; ---------------------------------------------------------------------- domasz · 2024-01-27 10:53 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function Imagecreatetruecolor(Width, Height: Integer): TBitmap;begin  Result := TBitmap.Create;  Result.SetSize(Width, Height);end; function ImageColorAllocate(Bmp: TBitmap; R,G,B: Byte): Cardinal;begin  Result := (B shl 16) + (G shl 8) + R;end; function ImageCreateFromJPEG(Filename: String): TBitmap;var jpg: TJpegImage;begin   jpg := TJpegImage.Create;   jpg.LoadFromFile(Filename);    Result := TBitmap.Create;   Result.Assign(jpg);    jpg.free;end; function Imagejpeg(Bmp: TBitmap; Filename: String; Compression: Byte): String;var jpg: TJpegImage;    Mem: TMemoryStream;begin  Result := '';  jpg := TJPEGImage.Create;  try    Jpg.Assign(Bmp);    Jpg.CompressionQuality := Compression;    Jpg.ProgressiveEncoding := False;    Jpg.Compress;     if Filename = '' then begin      Mem := TMemoryStream.Create;      jpg.SavetoStream(Mem);      Mem.Position := 0;      SetLength(Result, Mem.Size);      Mem.Read(Result[1], Mem.Size);      Mem.Free;   end   else    Jpg.SaveToFile(FileName);  finally    Jpg.Free;  end;end;   function ImageCopy(Dst, Src: TBitmap; DstX, DstY, SrcX, SrcY, SrcWid, SrcHei: Integer): Boolean;begin  Result := True;  Dst.Canvas.CopyRect(Rect(DstX, DstY, DstX+SrcWid, DstY+SrcHei), Src.Canvas, Rect(SrcX, SrcY, SrcX+SrcWid, SrcY+SrcHei));end; ---------------------------------------------------------------------- Cobaldblue · 2024-01-29 16:18 Hello! I have a lot to do this week. However, as soon as I find time I will consider the proposed solutions. But the solution to my problems seems to be within reach. Thank you for YOUR time and effort. However, I would like to briefly address the question of what the program should do. We have a program with a graphical display and the same program running on multiple servers. A second program takes screenshots of the respective screen at certain intervals and emails them to another server. Here the 6 or 8 screenshots were copied together into 4 or 2x 4 images on a web server and the image was then displayed on a large screen monitor. The web server should now be switched off for security concerns and the program should simply be run on the server. This saves you a step. Not really a big project.