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

Image Scaling

Name: Anonymous 2012-08-22 16:07

/prog/, do you have fast and good image scaling algorithm in the form of:
void resample(uint8_t *Dst, int DstW, int DstH, uint8_t *Src, int SrcW, int SrcH);

???

Name: Anonymous 2012-08-22 17:27

Okey. I found a function, but it uses floats, which are very slow.

void resample(uint32_t *Dst, int DstW, int DstH, uint32_t *Src, int SrcW, int SrcH) {
  int X, Y;
  float ScaleW = (float)SrcW/(float)DstW;
  float ScaleH = (float)SrcH/(float)DstH;
  for (Y = 0; Y < DstH; Y++) {
    for (X = 0; X < DstW; X++) {
      uint32_t C = Src[(int)(Y*ScaleH)*SrcW + (int)(X*ScaleW)];
      *Dst++ = C<<8;
    }
  }
}

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