Einzelnen Beitrag anzeigen

Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#5

AW: Bild auf Bild kopieren/übermalen & Transparenz

  Alt 15. Jun 2012, 10:50
Ich bastle mir für so etwas gerne eigene Komponenten auf Basis von TGraphicControl mit GDI +,
da Du JvImage verwenden möchtest, was ich meinte geht in diese Richtung, kann durchaus noch Fehler beinhalten.
(Annahme Imagelisten mit 32-Bit , PNG's)

Delphi-Quellcode:
function CombineIcons(FrontIcon, BackIcon: HIcon): HIcon;
// von http://www.swissdelphicenter.ch/torry/showcode.php?id=1636
var
  WinDC: HDC;
  FrontInfo: TIconInfo;
  FrontDC: HDC;
  FrontSv: HBITMAP;
  BackInfo: TIconInfo;
  BackDC: HDC;
  BackSv: HBITMAP;
  BmpObj: tagBitmap;
begin
  WinDC := GetDC(0);

  GetIconInfo(FrontIcon, FrontInfo);
  FrontDC := CreateCompatibleDC(WinDC);
  FrontSv := SelectObject(FrontDC, FrontInfo.hbmMask);
  GetIconInfo(BackIcon, BackInfo);
  BackDC := CreateCompatibleDC(WinDC);
  BackSv := SelectObject(BackDC, BackInfo.hbmMask);
  GetObject(FrontInfo.hbmMask, SizeOf(BmpObj), @BmpObj);
  BitBlt(BackDC, 0,0,BmpObj.bmWidth, BmpObj.bmHeight, FrontDC, 0,0,SRCAND);
  SelectObject(BackDC, BackInfo.hbmColor);
  DrawIconEx(BackDC, 0,0,FrontIcon, 0,0,0,0,DI_NORMAL);
  Result := CreateIconIndirect(BackInfo);
  SelectObject(FrontDC, FrontSv);
  DeleteDC(FrontDC);
  SelectObject(BackDC, BackSv);
  DeleteDC(BackDC);
  ReleaseDC(0,WinDC);
  DeleteObject(FrontInfo.hbmColor);
  DeleteObject(FrontInfo.hbmMask);
  DeleteObject(BackInfo.hbmColor);
  DeleteObject(BackInfo.hbmMask);
end;

procedure TForm5.SetButton(Picture:TPicture;ButtonList,ZahlenList:TImageList;ButtonIndex:Integer;StateIndex:Integer);
  var
   ico,ico2,ico3:TIcon;
   c:TMetafileCanvas;
  begin
      ico := TIcon.Create;
      ico2 := TIcon.Create;
      ico3 := TIcon.Create;
      try
       ButtonList.GetIcon(ButtonIndex,ico);
       if StateIndex>0 then
          begin
            ZahlenList.GetIcon(StateIndex,ico2);
            ico3.Handle := CombineIcons(ico2.Handle,ico.Handle);
            Picture.Assign(ico3);
          end else Picture.Assign(ico);
      finally
        ico.Free;
        ico2.Free;
        ico3.Free;
      end;

  end;

procedure TForm5.FormCreate(Sender: TObject);
begin
   SetButton(JVImage1.Picture,ImageButtons,ImageZahlen,0,1);
   SetButton(JVImage1.Pictures.PicEnter,ImageButtonsHoover,ImageZahlen,0,1);
end;
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)
  Mit Zitat antworten Zitat