baharbh
asked on
Unsigned chars
Part of code taken from small JPEG Code Library by Rich Geldreich
bool tga_writer::write_line(con st void *Pscan_line)
{
uchar *Psb = (uchar *)Pscan_line;
if (!Pfile)
return (true);
if (fwrite(Pscan_line, bytes_per_line, 1, Pfile) != 1) // bytes_per_line = 681, in this case
return (true);
return (false);
}
// Definition given in header file
typedef unsigned char uchar; /* 8 bits */
in main
=======
uchar *Pdb = Pbuf;
status = Pdst->write_line(Pbuf); // status if of type boolean
My question is
1. how can I assign the contents of Pbuf (within main program) or Pscan_line within
bool tga_writer::write_line(con st void *Pscan_line)
to say an array (1-D or 2-D) so that I can manipulate the contents.
bool tga_writer::write_line(con
{
uchar *Psb = (uchar *)Pscan_line;
if (!Pfile)
return (true);
if (fwrite(Pscan_line, bytes_per_line, 1, Pfile) != 1) // bytes_per_line = 681, in this case
return (true);
return (false);
}
// Definition given in header file
typedef unsigned char uchar; /* 8 bits */
in main
=======
uchar *Pdb = Pbuf;
status = Pdst->write_line(Pbuf); // status if of type boolean
My question is
1. how can I assign the contents of Pbuf (within main program) or Pscan_line within
bool tga_writer::write_line(con
to say an array (1-D or 2-D) so that I can manipulate the contents.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> bool tga_writer::write_line(con
>to say an array (1-D or 2-D) so that I can manipulate the contents.
bool tga_writer::write_line(con
{
char array [MAX_LINE_LENGTH];
uchar *Psb = (uchar *)Pscan_line;
if (!Pfile)
return (true);
memcpy ( array, Pscan_line, bytes_per_line ); //now your line is in 1D array
if (fwrite(Pscan_line, bytes_per_line, 1, Pfile) != 1) // bytes_per_line = 681, in this case
return (true);
return (false);
}