Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   ArteFakte in ScrollBar (https://www.delphipraxis.net/168309-artefakte-scrollbar.html)

EWeiss 15. Mai 2012 01:57

ArteFakte in ScrollBar
 
Habe mir mal eine procedure geschrieben als StretchBlt ersatz für GDI+.

Delphi-Quellcode:
procedure THookedScrollbar.GdipStretchBlt(DestDC, TmpDC: HDC; DestX, DestY, DestWidth,
  DestHeight, SrcX, SrcY, SrcWidth, SrcHeight: Integer);
var
  Graphics: Cardinal;
  hBmp: HBITMAP;
  hBmp2: HBITMAP;
  oldhBmp: HBITMAP;
  Img: Cardinal;
  SourceHdc: HDC;

begin

  hBmp := CreateDIBSection(DestDC, DestWidth, DestHeight, 32);
  oldhBmp := SelectObject(DestDC, hBmp);
  Render.Blit(DestDC, 0, 0, DestWidth, DestHeight, TmpDC, SrcX, SrcY, SRCCOPY);

  SourceHdc := GetDC(VScrollHwnd);

  if GdipCreateFromHDC(DestDC, Graphics) = S_OK then
  begin
    hBmp2 := GetCurrentObject(DestDC, OBJ_BITMAP);
    GdipCreateBitmapFromHBITMAP(hBmp2, 0, Pointer(Img));
    GdipSetInterpolationMode(Graphics, 2); //QualityModeHigh

    GdipDrawImageRectRect(Graphics, Img, 0, 0, DestWidth, DestHeight,
      0, 0, SrcWidth, SrcHeight, 2, nil, False, nil);

    GdipDeleteGraphics(Graphics);
    GdipDisposeImage(Img);
  end;

  Render.Blit(SourceHdc, DestX, DestY, VertRect.Right, VertRect.Bottom, DestDC, 0, 0,
    SRCCOPY);

   SelectObject(DestDC, oldhBmp);
   DeleteObject(hBmp);
  DeleteDC(SourceHdc);
end;
Mein Problem ist das bei der Bar ArteFakte zurückbleiben.
Kann nicht erkennen woran das liegen könnte.

Die VBar ist 13 Pixel hoch nach acht Pixeln wird aber plötzlich nur noch die hälfte in der breite gezeichnet.
Habe mal ein Bild angehängt.

Die VScroll sieht gestretcht (GDI+) zwar besser aus der Nachteil dabei ist das ich nach jedem Bitmap
dieses auf das VScrollHwnd zeichnen muss was zur folge hat das die Bitmaps leicht flickern beim Scrollen.
Bei der verwendung von StretchBlt ist das nicht nötig.
Hab da noch keine Idee wie ich das am besten händeln kann.

Vielleicht hat ja jemand ne andere idee ;)

gruss


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:33 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz