Thema: Delphi Reflektion vom Image

Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#1

Reflektion vom Image

  Alt 1. Mai 2017, 01:21
Ich möchte eine Reflektion von einem Image erstellen.

Delphi-Quellcode:
    if GDIP_CreateFromHDC(ImgHDC, Graphics) = OK then
    begin
      if GDIP_DrawImageRectI(Graphics, Img, 0, 0, imgW, imgH) = OK then
      begin
        GetObject(hbmReturn, sizeof(bm), @bm);
        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[3] - round(AlphaStep), 0);
            pBits[3] := Alpha;
            pBits := pBits + 4;
          end;
          AlphaStep := AlphaStep - UseStep;
        end;

        for y := 0 to (h - 1) do
        begin
          for x := 0 to (w - 1) do
          begin
            AlphaCoef := (pBits[3] / 255);
            pBits[2] := pBits[2] div round(AlphaCoef);
            pBits[1] := pBits[1] div round(AlphaCoef);
            pBits[0] := pBits[0] div round(AlphaCoef);
            pBits := pBits + 4;
          end;
        end;
        imgH := UseImgH;
        Result := hbmReturn;
      end;
      GDIP_DeleteGraphics(Graphics);
    end;
Es scheint das die verwendete Definition falsch ist.
pBits: Array of PByte will nicht.
pBits: PByte verursacht Zugriffs Verletzung. Weil pBits[2] und die anderen werte immer 0 sind.

was läuft falsch.
Vielleicht nen Pointer vergessen?

pBits := @bm.bmBits; ?
Aber es sind eigentlich beides Pointer.

AlphaCoef := (pBits[3] / 255);
Ist 0 führt dann natürlich zum AV.

gruss

Geändert von EWeiss ( 1. Mai 2017 um 01:32 Uhr)
  Mit Zitat antworten Zitat