1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| unit matcolli;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, crt,
StdCtrls, Buttons, IntfGraphics, LCLType, LCLProc, LCLIntf, GraphType;
const tailleimagex=2000;
const tailleimagey=1000;
type cmatricecollision = class
public
mat:array[0..tailleimagex,0..tailleimagey] of integer;
aimage:TLazIntfImage;
constructor createterrain();
end;
implementation
constructor cmatricecollision.createterrain;
var lRawImage: TRawImage;
i,j:integer;
begin
// create a TLazIntfImage with 32 bits per pixel, alpha 8bit, red 8 bit, green 8bit, blue 8bit,
// Bits In Order: bit 0 is pixel 0, Top To Bottom: line 0 is top
lRawImage.Init;
lrawimage.Description.Init_BPP32_B8G8R8A8_BIO_TTB(0,0);
lRawImage.CreateData(false);
AImage := TLazIntfImage.Create(0,0);
try
AImage.SetRawImage(lRawImage); // Load an image from disk.
AImage.LoadFromFile('./images/terrains/plateforme.bmp'); // It uses the file extension to select the right registered image reader.
debugln(['imagecreator ',AImage.Width,' ',AImage.Height]); // The AImage will be resized to the width, height of the loaded image.
finally
for i:=0 to tailleimagex-1 do begin
for j:=0 to tailleimagey-1 do begin
if fpcolortotcolor(aimage.colors[i,j])=clblack then begin
mat[i,j]:=1;
aimage.colors[i,j]:=tcolortofpcolor(clgreen);
end;
end;
end;
end;
end; |
Partager