GDI resources vanished when realizing a palette in a TImage component

I have a problem with the following routine. It eats my GDI resources
and after some calls the system crashes.
This routine tries to blit a bitmap in a TImage component. For this
purpose, I realize the palette of the bitmap into the TImage.Canvas:

  {* Build palette *}

  GetMem (pALogPalette, SizeOf (TLogPalette) + (256 - 1) * SizeOf
(TPalet{*word*249}try));
  pALogPalette^.palVersion := $300;
  pALogPalette^.palNumEntries := 256;
  for wCount := 0 to 255 do
  begin
    pALogPalette^.palPalEntry[wCount].peRed := LOBYTE (pbPalette[3 *
wCount]) SHL 2;
    pALogPalette^.palPalEntry[wCount].peGreen := LOBYTE (pbPalette[3 *
wCount + 1]) SHL 2;
    pALogPalette^.palPalEntry[wCount].peBlue := LOBYTE (pbPalette[3 *
wCount + 2]) SHL 2;
    pALogPalette^.palPalEntry[wCount].peFlags := PC_NOCOLLAPSE;
  end;
  AHPalette := CreatePalette (pALogPalette^);
  FreeMem (pALogPalette);

  {* Set palette *}

  OldHPalette := SelectPalette (ACanvas.Handle,
                                AHPalette,
                                False);
  DeleteObject (AHPalette);
  DeleteObject (OldHPalette);
  RealizePalette (ACanvas.Handle);

This routine works fine when drawing in a window, but not when drawing
in a TImage: it eats the GDI resources. Another point: The TImage
component is fine, because it keeps what you blit in its canvas so you
do not need to patch an onPaint event (which you should do for a
TWindow). How is this possible ? Does anybody have more informations
about what the TImage control does when you blit something in its
canvas ?