Exemple #1
0
int jas_stream_write(jas_stream_t *stream, const void *buf, int cnt)
{
	int n;
	const char *bufptr;

	bufptr = buf;

	n = 0;
	while (n < cnt) {
		if (jas_stream_putc(stream, *bufptr) == EOF) {
			return n;
		}
		++bufptr;
		++n;
	}

	return n;
}
int iJP2WriteLine(jas_image_t *image, int row, int cmpno, T *data)
{
  jas_image_cmpt_t *cmpt = image->cmpts_[cmpno];

  if (jas_stream_seek(cmpt->stream_, (cmpt->width_ * row) * cmpt->cps_, SEEK_SET) < 0) 
    return 0;

  for (int j = 0; j < cmpt->width_; j++) 
  {
    jas_seqent_t v = iJP2Int2Bits(*data++, cmpt->prec_, cmpt->sgnd_);

    for (int k = 0; k < cmpt->cps_; k++) 
    {
      int c = (v >> (8 * (cmpt->cps_ - 1))) & 0xff;
      if (jas_stream_putc(cmpt->stream_, (imbyte)c) == EOF) 
        return 0;

      v <<= 8;
    }
  }

  return 1;
}