Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Those who don't understand PNG...

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2010-11-22 6:25

...are doomed to reinvent it, poorly:


unsigned long stride = width * pixel_bytes;

for (unsigned long y = 0; y < height; y++) {
  unsigned char* prev_line = buff + (y  - 1) * stride;
  unsigned char* dst_line  = buff + y * stride;

  switch (cmds[y]) {
    case 1:
      for (unsigned long x = pixel_bytes; x < stride; x++) {
        dst_line[x] = dst_line[x - pixel_bytes] - dst_line[x];
      }
      break;

    case 2:
      for (unsigned long x = 0; x < stride; x++) {
        dst_line[x] = prev_line[x] - dst_line[x];
      }
      break;

    case 4:
      for (unsigned long x = pixel_bytes; x < stride; x++) {
        dst_line[x] = (prev_line[x] + dst_line[x - pixel_bytes]) / 2 - dst_line[x];
      }
      break;
  }
}

Name: Anonymous 2010-11-22 23:51

>>14
glibc?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List