Example #1
0
unsigned int JDMwrite_int32 (int32 *ss, unsigned int n, FILE *fp) /*{{{*/
{
   unsigned int nwrote;

#ifdef NEEDS_BYTE_SWAP
   byte_swap32 ((unsigned char *) ss, n);
#endif
   nwrote = fwrite (ss, 4, n, fp);
#ifdef NEEDS_BYTE_SWAP
   byte_swap32 ((unsigned char *) ss, n);
#endif
   return nwrote;
}
Example #2
0
static void write_rgb_alpha_to_rgb_alpha (png_struct *png, png_byte *data, SLindex_Type num_cols, png_byte *tmpbuf)
{
   unsigned char *data_max;
   unsigned char *p;

   if (Is_Little_Endian)
     {
	byte_swap32 ((unsigned char *) data, (unsigned char *) tmpbuf, num_cols);
	data = tmpbuf;
     }
   data_max = data + 4 * num_cols;
   p = tmpbuf;
   /* Change ARGBARGB... to RGBARGBA... */
   while (data < data_max)
     {
	unsigned char a = data[0];
	p[0] = data[1];
	p[1] = data[2];
	p[2] = data[3];
	p[3] = a;
	data += 4;
	p += 4;
     }
   png_write_row (png, tmpbuf);
}
Example #3
0
static void fixup_array_rgb (SLang_Array_Type *at)
{
   SLindex_Type num_rows, num_cols, row;
   unsigned char *data;

   num_rows = at->dims[0];
   num_cols = at->dims[1];
   data = (unsigned char *) at->data;

   /* Convert RGBRGBRGB....  to 0RGB0RGB0RGB ... */
   for (row = 0; row < num_rows; row++)
     {
	unsigned char *p = data + 3*num_cols;
	unsigned char *q = p + num_cols;
	while (p != data)
	  {
	     *(--q) = *(--p);
	     *(--q) = *(--p);
	     *(--q) = *(--p);
	     *(--q) = 0;	       /* or 0xFF */
	  }
	data += 4*num_cols;
     }

   if (Is_Little_Endian)
     byte_swap32 ((unsigned char *)at->data, (unsigned char *)at->data, at->num_elements);
}
Example #4
0
unsigned int JDMread_int32 (int32 *ss, unsigned int n, FILE *fp) /*{{{*/
{
   unsigned int nread = fread (ss, 4, n, fp);
#ifdef NEEDS_BYTE_SWAP
   byte_swap32 ((unsigned char *) ss, nread);
#endif
   return nread;
}
Example #5
0
unsigned char *JDMstr_read_float32 (float32 *ss, unsigned int n, unsigned char *s) /*{{{*/
{
   unsigned int len = 4 * n;
   if (s != (unsigned char *)ss) memcpy ((char *) ss, (char *) s, len);

#ifdef NEEDS_BYTE_SWAP
   byte_swap32 ((unsigned char *)ss, n);
#endif
   return s + len;
}
Example #6
0
unsigned char *JDMstr_write_int32 (int32 *ss, unsigned int n, unsigned char *s) /*{{{*/
{
   unsigned int len = 4 * n;

   memcpy ((char *) s, (char *) ss, len);

#ifdef NEEDS_BYTE_SWAP
   byte_swap32 ((unsigned char *) s, n);
#endif
   return s + len;
}
Example #7
0
static void fixup_array_rgba (SLang_Array_Type *at)
{
   unsigned char *data, *data_max;

   data = (unsigned char *) at->data;
   data_max = data + 4*at->num_elements;

   /* RGBARGBA -> ARGBARGB */
   while (data < data_max)
     {
	unsigned char a = data[3];
	data[3] = data[2];
	data[2] = data[1];
	data[1] = data[0];
	data[0] = a;
	data += 4;
     }
   if (Is_Little_Endian)
     byte_swap32 ((unsigned char *)at->data, (unsigned char *)at->data, at->num_elements);
}
Example #8
0
static int byteswap (int order, unsigned char *b,  unsigned int size, unsigned int num)
{
   if (Native_Byte_Order == order)
     return 0;

   switch (size)
     {
      case 2:
	byte_swap16 (b, num);
	break;
      case 4:
	byte_swap32 (b, num);
	break;
      case 8:
	byte_swap64 (b, num);
	break;
      default:
	return -1;
     }

   return 0;
}
Example #9
0
static void write_rgb_to_rgb (png_struct *png, png_byte *data, SLindex_Type num_cols, png_byte *tmpbuf)
{
   SLindex_Type i;
   png_byte *p, *q;

   if (Is_Little_Endian)
     {
	byte_swap32 ((unsigned char *) data, (unsigned char *) tmpbuf, num_cols);
	p = tmpbuf;
     }
   else p = data;

   /* ARGBARGB... -> RGBRGBRGB */
   q = tmpbuf;
   for (i = 0; i < num_cols; i++)
     {
	p++;
	*q++ = *p++;
	*q++ = *p++;
	*q++ = *p++;
     }
   png_write_row (png, tmpbuf);
}