fork download
  1. program ideone;
  2.  
  3. uses SysUtils;
  4.  
  5. //const YSize=1080;
  6. //const XSize=1920;
  7. const YSize=3;
  8. const XSize=4;
  9. type TTestRecord=record Y,X,Idx:Integer; end;
  10. type RGBTriple=record R,G,B:Byte; end;
  11. type TTestTable=array[0..3] of TTestRecord;
  12. type TBitMask=array[0..YSize-1,0..XSize-1] of RGBTriple;
  13. type PBitMask=^TBitMask;
  14. type TBits=array[0..YSize*XSize-1] of RGBTriple;
  15. type PBits=^TBits;
  16. function XY2Idx(X,Y:Integer):Integer; begin XY2Idx:=Y*XSize+X; end;
  17.  
  18. procedure test(const Bits:TBits;const BitMask:TBitMask);
  19. var R:TTestRecord;
  20. var Y,X,Idx:Integer;
  21. begin
  22. for Y:=0 to YSize-1 do
  23. begin
  24. for X:=0 to XSize-1 do
  25. begin
  26. Idx:=XY2Idx(X,Y);
  27. WriteLn('Y:=',Y,'; X:=',X,'; Idx:=',Idx,' ',Int64(@Bits[Idx]),' - ',Int64(@BitMask[Y,X]));
  28. end;
  29. end;
  30. end;
  31.  
  32. procedure go1;
  33. var Bits:PBits;
  34. var BitMask:TBitMask;
  35. begin
  36. Bits:=@BitMask[0,0];
  37. test(Bits^,BitMask);
  38. end;
  39.  
  40. procedure go2;
  41. var Bits:TBits;
  42. var BitMask:PBitMask;
  43. begin
  44. BitMask:=@Bits[0];
  45. test(Bits,BitMask^);
  46. end;
  47.  
  48. procedure go0;
  49. var Bits:TBits;
  50. var BitMask:TBitMask;
  51. begin
  52. WriteLn(SizeOf(Bits),' => ',SizeOf(BitMask));
  53. end;
  54.  
  55. begin
  56. go0;
  57. WriteLn;
  58. go1;
  59. WriteLn;
  60. go2;
  61. end.
Success #stdin #stdout 0s 4436KB
stdin
Standard input is empty
stdout
36 => 36

Y:=0; X:=0; Idx:=0 140733458983568 - 140733458983568
Y:=0; X:=1; Idx:=1 140733458983571 - 140733458983571
Y:=0; X:=2; Idx:=2 140733458983574 - 140733458983574
Y:=0; X:=3; Idx:=3 140733458983577 - 140733458983577
Y:=1; X:=0; Idx:=4 140733458983580 - 140733458983580
Y:=1; X:=1; Idx:=5 140733458983583 - 140733458983583
Y:=1; X:=2; Idx:=6 140733458983586 - 140733458983586
Y:=1; X:=3; Idx:=7 140733458983589 - 140733458983589
Y:=2; X:=0; Idx:=8 140733458983592 - 140733458983592
Y:=2; X:=1; Idx:=9 140733458983595 - 140733458983595
Y:=2; X:=2; Idx:=10 140733458983598 - 140733458983598
Y:=2; X:=3; Idx:=11 140733458983601 - 140733458983601

Y:=0; X:=0; Idx:=0 140733458983568 - 140733458983568
Y:=0; X:=1; Idx:=1 140733458983571 - 140733458983571
Y:=0; X:=2; Idx:=2 140733458983574 - 140733458983574
Y:=0; X:=3; Idx:=3 140733458983577 - 140733458983577
Y:=1; X:=0; Idx:=4 140733458983580 - 140733458983580
Y:=1; X:=1; Idx:=5 140733458983583 - 140733458983583
Y:=1; X:=2; Idx:=6 140733458983586 - 140733458983586
Y:=1; X:=3; Idx:=7 140733458983589 - 140733458983589
Y:=2; X:=0; Idx:=8 140733458983592 - 140733458983592
Y:=2; X:=1; Idx:=9 140733458983595 - 140733458983595
Y:=2; X:=2; Idx:=10 140733458983598 - 140733458983598
Y:=2; X:=3; Idx:=11 140733458983601 - 140733458983601