POV-Ray : Newsgroups : povray.general : Outputting raw pixel data? : Re: Outputting raw pixel data? Server Time
1 Aug 2024 22:16:46 EDT (-0400)
  Re: Outputting raw pixel data?  
From: scott
Date: 1 Apr 2005 11:07:34
Message: <424d71c6@news.povray.org>
Michael Zier wrote:
> "scott" <sco### [at] spamcom> schrieb im Newsbeitrag
> news:424c0a27@news.povray.org...
>
>> So this line_data[i][pBLUE] is a single float value that I can just
>> write directly to a file rather than using *255.0 and floor()...
>>
> If you compile a Win version with this, I'd be quite interested in it
> too...

OK, well all I did was to modify the pvbmp.cpp file to output floats instead
of bytes.  It's all a bit of a hack but I rarely use bmp output anyway.  It
does what I want (which will probably be explained around here somewhere at
some point...) but isn't very clean:

This is the updated BMP_Image::Write_Line function below, if you can't
compile it then drop me an email and I'll send you the windows .exe (i'm
scottgboham at hotmail.com).  Note that the file size is much bigger than
the BMP header suggests due to this...

void BMP_Image::Write_Line (COLOUR *line_data)
{
  int pad = (4 - ((width * 3) % 4)) & 0x03 ;
  int i;
  OStream& out = *out_file ;

  if (!out.seekg (14 + 40 + (height - 1 - line_number) * (12 * width )))
    Error ("Error seeking in BMP image.") ;

  unsigned long *t;
  float tmp;
  float *t2;

  t2 = &tmp;
  t  = (unsigned long *) &tmp;

  for (i = 0 ; i < width ; i++)
  {
    tmp = (float) line_data [i] [pBLUE];   out << ( *t ) ;
    tmp = (float) line_data [i] [pGREEN];  out << ( *t ) ;
    tmp = (float) line_data [i] [pRED];    out << ( *t ) ;


  }

  if (!out)
    Error ("Error writing to BMP image.") ;

  line_number++;

  out.flush () ;
}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.