Yo tampoco entendí bien que es lo que buscas hacer.
Copie y pegue tu pregunta en ChatGPT y me dio escribió un código. No se si sea lo que busques
Código Delphi
[-]
unit MainFormUnit;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, System.Generics.Collections;
type
TCoordinate = record
X, Y: Integer;
DataValue: Integer;
end;
TMainForm = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Image1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
private
CoordinatesList: TList;
MaxDataValue: Integer;
MinDataValue: Integer;
procedure LoadDataFromFile(const FileName: string);
procedure DrawImage;
procedure CenterImage;
public
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
procedure TMainForm.FormCreate(Sender: TObject);
begin
CoordinatesList := TList.Create;
LoadDataFromFile('ruta_del_archivo.txt');
DrawImage;
CenterImage;
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
CoordinatesList.Free;
end;
procedure TMainForm.LoadDataFromFile(const FileName: string);
var
FileStream: TStreamReader;
X, Y, DataValue: Integer;
Coordinate: TCoordinate;
begin
if not FileExists(FileName) then
raise Exception.Create('El archivo no existe.');
FileStream := TStreamReader.Create(FileName);
try
while not FileStream.EndOfStream do
begin
FileStream.ReadLine;
if TryStrToInt(FileStream.ReadLine, X) and
TryStrToInt(FileStream.ReadLine, Y) and
TryStrToInt(FileStream.ReadLine, DataValue) then
begin
Coordinate.X := X;
Coordinate.Y := Y;
Coordinate.DataValue := DataValue;
CoordinatesList.Add(Coordinate);
if DataValue > MaxDataValue then
MaxDataValue := DataValue;
if DataValue < MinDataValue then
MinDataValue := DataValue;
end;
end;
finally
FileStream.Free;
end;
end;
procedure TMainForm.DrawImage;
var
I: Integer;
DataRange: Integer;
begin
Image1.Picture.Bitmap.SetSize(Image1.Width, Image1.Height);
DataRange := MaxDataValue - MinDataValue;
for I := 0 to CoordinatesList.Count - 1 do
begin
with CoordinatesList[i] do
begin
Image1.Picture.Bitmap.Canvas.Pixels[X, Y] := RGB(0, Trunc(255 * (DataValue - MinDataValue) / DataRange), 0);
end;
end;
end;
procedure TMainForm.CenterImage;
var
ImageRect, ClientRect: TRect;
begin
ImageRect := Image1.BoundsRect;
ClientRect := ClientRect;
OffsetRect(ImageRect, (ClientRect.Width - ImageRect.Width) div 2, (ClientRect.Height - ImageRect.Height) div 2);
Image1.BoundsRect := ImageRect;
end;
procedure TMainForm.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
Image1.BeginDrag(True);
end;
procedure TMainForm.Image1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
var Handled: Boolean);
begin
if WheelDelta > 0 then
Image1.Width := Image1.Width + 10
else
Image1.Width := Image1.Width - 10;
Image1.Height := Image1.Width;
CenterImage;
Handled := True;
end;
end.