Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
RTC_Marine

Doom Image format

Recommended Posts

Csabo (or anyone), could you please take a look at this piece of code and tell me what I am doing wrong? I know I am missing some pieces from that code for sure:
http://russell.slipgate.org/text/img-problem.txt

as you see, I haven't done alot of graphics programming. :/

Also, this is the result of the function:
http://russell.slipgate.org/images/prob1.bmp
http://russell.slipgate.org/images/prob2.bmp

any help would be appreciated, thanks.

Share this post


Link to post

The problem is in the inner loop:

for b := 0 to DPic.Height-1 do
begin
  dStream.Read(pixels,1);
  TByteArray(Result.ScanLine[b]^)[a] := pixels;
end;
This won't work. Instead you need a while loop, which stops when a $FF is reached. Here's an example sequence from an imaginary image. If you can process this, you are in business:

$10 $03 $AA $F1 $F2 $F3 $AA
$20 $05 $AA $F1 $F2 $F3 $F4 $F5 $AA
$FF

$10 means the sequence starts from $10 pixels down. $03 means three pixels will follow, however there's an extra byte in the beginning and end, so the $AA's are ALL skipped, you should ignore those bytes completely. The $Fx values are the actual pixels. Then another 5 pixel sequence from $20, and the then $FF tells you this column is done. Every other pixel in this column is 'undefined' or 'transparent' if you will.

This is the basic doom image format, for 'tall sprites' it's a bit different, but once you have the basic, that change will be easy. Hope this helps.

Share this post


Link to post

thanks for your reply :)

after much hair pulling and human sacrifices, I managed to fabricate this:

 for a := 0 to DPic.Width-1 do
  begin
  dStream.Seek(DPic.ColumnOffsets[a], soFromBeginning);
  rowstart := 0;
  while rowstart <> 255 do
  begin
   dStream.Read(rowstart,1);
   if rowstart = 255 then break;
   dStream.Read(numpixels,1);
   dStream.Read(dummy,1);
   for b := 0 to numpixels-1 do
    begin
     dStream.Read(pixels,1);
     TByteArray(Result.ScanLine[b+rowstart]^)[a] := pixels;
    end;
   dStream.Read(dummy,1);
  end;
 end;
it seems to work, I cant see any visual problems so far. :)

Share this post


Link to post

hehe kinda, only this will only be supporting the doom games and will only support vanilla doom - no ports in other words, just trying to make a wintex clone really. :)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×