Skip to main content
GameDev.net gamedev.net
🔒 Locked

DirectDraw Pixel Manipulation

Started by chlupp2000 Jul 29, 2001 at 4:36 AM 4 replies 500+ views
Original Post
chlupp2000
chlupp2000
Hello! I have nearly all tried to get this thing working, but now I don''t know what to do. I am not able to manipulate a single pixel from a DirectDraw Surface. Here''s my code:
ddsd: TDDSurfaceDesc2;
Primary: IDirectDrawSurface7;
X,Y: Integer;

Primary.GetSurfaceDesc(ddsd);
if Primary.Lock(nil,ddsd, DDLOCK_SURFACEMEMORYPTR or DDLOCK_WAIT,0) = DD_OK then
  begin
    try
      begin
        for x:=0 to 1023 do
        begin
          for y:=0 to 767 do
          begin
            PByte(Integer(ddsd.lpSurface)+Y*ddsd.lpitch+X)^:= RGB(50,50,50);
          end;
        end;
      end;
    finally
      Primary.Unlock(nil);
    end;
  end;
 
Maybe someone can help me (and post his code)? thanks chlupp Starbyte Developments
turbo
turbo
Try using...


pdword(integer(LockedSurfaceDesc.lpsurface) + // surface pointer
y * LockedSurfaceDesc.lpitch + x * 3)^ :=
(r shl 16) or (g shl 8) or b; // Could use RGB(r,g,b)
end;


Since RGB values are DWORDS not bytes. You also may have some locking issues. I use...


LockedRect := Rect(0, 0, LockedSurfaceDesc.dwWidth, LockedSurfaceDesc.dwHeight);
if LockedSurface.Lock(@LockedRect, LockedSurfaceDesc, DDLOCK_SURFACEMEMORYPTR + DDLOCK_WAIT,0) <> DD_OK then // etc...


but there are many ways to skin a cat
[ Michael Wilson | turbo sys-op | turbo.gamedev.net ]
chlupp2000
chlupp2000
Thanks for replying, I''ll try it.

cu
chlupp20000
chlupp2000
chlupp2000
Yeah, it''s working!

Thank you!

chlupp2000
LoreKeeper
LoreKeeper
Try looking at the Pixel code in TurboPixel or PixelCore... although they are mostly DelphiX related, the code still applies to the general case. And those pixel routines are still faster then the code above.
L-Tryosine
L-Tryosine
Hey, this just solved a problem that I was having too!!!

Thanks guys!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.