Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Solution?

  1. #11

    Solution?

    Please don't let me catch any of you using Pixels again EVER :evil: . I'm making the assumption that you're using 24 bit color and your DestRect is clipped to screen size.
    [pascal]procedure TConsole.FillRectDarken(Const DestRect: TRect; Const DarkenBy: Integer);
    Var
    desc: TDDSurfaceDesc;
    Color: PByte;
    val, i, j, NextLine: Integer;
    Begin
    FillChar(desc, SizeOf(desc), 0);
    gmScreen.Surface.Lock(DestRect, desc);
    Color:= PByte(desc.lpSurface);
    NextLine:= desc.lPitch - 3 * (DestRect.Right - DestRect.Left + 1);
    for j := DestRect.Top to DestRect.Bottom do
    begin
    for i := DestRect.Left to DestRect.Right do
    begin
    Val:= Color^;
    dec(Val, DarkenBy);
    if Val<0 then Val:= 0;
    Color^:= Val;
    inc(Color);

    Val:= Color^;
    dec(Val, DarkenBy);
    if Val<0 then Val:= 0;
    Color^:= Val;
    inc(Color);

    Val:= Color^;
    dec(Val, DarkenBy);
    if Val<0 then Val:= 0;
    Color^:= Val;
    inc(Color);
    end;
    inc(Color, NextLine);
    end;
    gmScreen.Surface.UnLock;
    end;[/pascal]

  2. #12

    Solution?

    AHH! You were using Pixels. Well then it's no surprise that it was slow as hell.
    Nice job Paulius.
    Ask me about the xcess game development kit

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •