uses JPeg;
var
bm: TBitmap;
procedure TForm1.FormCreate(Sender: TObject);
var
jp: TJpegImage;
begin
jp := TJpegImage.create;
jp.loadfromfile('monde.jpg');
bm := TBitmap.create;
bm.assign(jp);
jp.free;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
bm.free;
end;
function mondphase(dtm: TDate): integer;
var
c, e, d: double;
b: integer;
year, month, day: word;
begin
decodeDate(dtm, year, month, day);
if (month < 3) then
begin
dec(year);
inc(month, 12);
end;
inc(month);
c := 365.25 * year;
e := 30.6 * month;
d := c + e + day - 694039.09;
d := d / 29.5305882;
b := trunc(d);
d := d - b;
b := round(d * 8);
if (b >= 8) then b := 0;
result := b;
end;
// Beispielaufruf
procedure TForm1.Button1Click(Sender: TObject);
var
s: string;
mph: integer;
begin
mph := mondphase(strtodate('25.02.2012'));
case mph of
0: s := 'Neumond';
1: s := 'Zunehmender Halbmond';
2: s := 'Erstes Viertel Mond';
3: s := 'Zunehmender Mond';
4: s := 'Vollmond';
5: s := 'Abnehmender Mond';
6: s := 'Letztes Viertel Mond';
7: s := 'Abnehmender Halbmond';
else s := 'Fehler';
end;
label1.caption := s;
if mph in [0..7] then
canvas.copyrect(rect(20, 10, 20 + bm.height, 10 + bm.height), bm.canvas,
rect(mph * bm.height, 0, mph * bm.height + bm.height, bm.height));
end;