Beispiel #1
0
static int
read_pk_char_header (struct pk_header_ *h, unsigned char opcode, FILE *fp)
{
  ASSERT(h);

  if ((opcode & 4) == 0) { /* short */
    h->pkt_len = (opcode & 3) * 0x100U + get_unsigned_byte(fp);
    h->chrcode = get_unsigned_byte(fp);
    h->wd = get_unsigned_triple(fp);     /* TFM width */
    h->dx = get_unsigned_byte(fp) << 16; /* horizontal escapement */
    h->dy = 0L;
    h->bm_wd    = get_unsigned_byte(fp);
    h->bm_ht    = get_unsigned_byte(fp);
    h->bm_hoff  = get_signed_byte(fp);
    h->bm_voff  = get_signed_byte(fp);
    h->pkt_len -= 8;
  } else if ((opcode & 7) == 7) { /* long */
    h->pkt_len = get_unsigned_quad(fp);
    h->chrcode = get_signed_quad(fp);
    h->wd = get_signed_quad(fp);
    h->dx = get_signed_quad(fp); /* 16.16 fixed point number in pixels */
    h->dy = get_signed_quad(fp);
    h->bm_wd    = get_signed_quad(fp);
    h->bm_ht    = get_signed_quad(fp);
    h->bm_hoff  = get_signed_quad(fp);
    h->bm_voff  = get_signed_quad(fp);
    h->pkt_len -= 28;
  } else { /* extended short */
    h->pkt_len = (opcode & 3) * 0x10000UL + get_unsigned_pair(fp);
    h->chrcode = get_unsigned_byte(fp);
    h->wd = get_unsigned_triple(fp);
    h->dx = get_unsigned_pair(fp) << 16;
    h->dy = 0x0L;
    h->bm_wd    = get_unsigned_pair(fp);
    h->bm_ht    = get_unsigned_pair(fp);
    h->bm_hoff  = get_signed_pair(fp);
    h->bm_voff  = get_signed_pair(fp);
    h->pkt_len -= 13;
  }

  h->dyn_f     = opcode / 16;
  h->run_color = (opcode & 8) ? 1 : 0;

  if (h->chrcode > 0xff)
  {
    WARN("Unable to handle long characters in PK files: code=0x%04x", h->chrcode);
    return  -1;
  }

  return  0;
}
Beispiel #2
0
signed int get_signed_triple(FILE *file)
{
  int i;
  signed int triple = get_signed_byte(file);
  for (i=0; i<2; i++) {
    triple = (triple << 8) | get_unsigned_byte(file);
  }
  return triple;
}
Beispiel #3
0
int32_t get_signed_quad(FILE *file)
{
  int i;
  int32_t quad = get_signed_byte(file);
  for (i=0; i<3; i++) {
    quad = (quad << 8) | get_unsigned_byte(file);
  }
  return quad;
}
Beispiel #4
0
signed short get_signed_pair (FILE *file)
{
  signed short pair = get_signed_byte(file);
  pair = (pair << 8) | get_unsigned_byte(file);
  return pair;
}