1 Reply Latest reply on Oct 27, 2010 12:16 AM by unique_screenname_here

    How to scale image?

    Y.Boy Level 1

      I input a image (size: 200x200 px), and I want to scale it in pixel bender. I want to output smaller image (size: 20x20 px) .

      HOW ?

      THANKS:)

        • 1. Re: How to scale image?
          unique_screenname_here Level 3

          You could do something like this:

           

          <languageVersion : 1.0;>

          kernel constrained_scale

          <  

              namespace: "com.moc";

                 vendor: "foo";

                version: 1;

          >

          {

              parameter float scale

              <

                  defaultValue:  1.000;

                      minValue:  0.001;

                      maxValue: 10.000;

          >;

           

              input  image4 src;

              output pixel4 dst;

           

              void

              evaluatePixel()

              {

                  float2 scaledCoordinate = outCoord() * float2x2(1.0/scale, 0, 0, 1.0/scale);

                  dst = sampleNearest(src, scaledCoordinate);

              }

          }