Thema: Delphi Reflektion vom Image

Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.070 Beiträge
 
Delphi 10.4 Sydney
 
#4

AW: Reflektion vom Image

  Alt 2. Mai 2017, 10:07
Delphi-Quellcode:
function MussteHaltNochSinnvollBeiDirEinfügen(hbmReturn: HGDIOBJ): HGDIOBJ;
var
  pBits: PRGBQuad; // <----- richtigen Datentyp nehmen!
  // Tipp: http://www.delphipraxis.net/155296-multipletexture-loader.html#post1056155
begin
  if GDIP_CreateFromHDC(ImgHDC, Graphics) = OK then
  begin
    if GDIP_DrawImageRectI(Graphics, Img, 0, 0, imgW, imgH) = OK then
    begin
      // sicherheitshalber Initialisieren, schadet ja nicht
      FillChar(bm, SizeOf(bm), 0);

      // nur weitermachen wenn Funktion GetObject Erfolg meldet
      if GetObject(hbmReturn, SizeOf(bm), @bm) <> 0 then
      begin
        pBits := bm.bmBits;

        GDIP_ImageRotateFlip(Img, 6); // Rotate180FlipX

        GDIP_DrawImageRectI(Graphics, Img, 0, integer(imgH), integer(imgW),
          integer(imgH));

        w := imgW;
        h := imgH;
        AlphaStep := 256;
        UseStep := 128 / (UseImgH - h);

        // Image Reflektieren
        for y := 0 to (UseImgH - h) - 1 do
        begin
          for x := 0 to (w - 1) do
          begin
            Alpha := MAX(pBits.rgbReserved - round(AlphaStep), 0);
            pBits.rgbReserved := Alpha;

            Inc(pBits);
          end;
          AlphaStep := AlphaStep - UseStep;
        end;

        for y := 0 to (h - 1) do
        begin
          for x := 0 to (w - 1) do
          begin
            AlphaCoef := (pBits.rgbReserved / 255);
            pBits.rgbBlue := round(pBits.rgbBlue / AlphaCoef);
            pBits.rgbGreen := round(pBits.rgbGreen / AlphaCoef);
            pBits.rgbRed := round(pBits.rgbRed / AlphaCoef);

            Inc(pBits);
          end;
        end;
        imgH := UseImgH;
        Result := hbmReturn;
      end;
      GDIP_DeleteGraphics(Graphics);
    end;
  end;
end;
  Mit Zitat antworten Zitat