2009-03-02 07:32:00 +00:00
|
|
|
// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person
|
|
|
|
// obtaining a copy of this software and associated documentation
|
|
|
|
// files (the "Software"), to deal in the Software without
|
|
|
|
// restriction, including without limitation the rights to use,
|
|
|
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following
|
|
|
|
// conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be
|
|
|
|
// included in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
// OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
#include <nvtt/nvtt.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2009-03-05 05:34:28 +00:00
|
|
|
nvtt::CompressionOptions compressionOptions;
|
2009-03-15 10:18:54 +00:00
|
|
|
compressionOptions.setFormat(nvtt::Format_BC1);
|
|
|
|
|
2009-03-05 05:34:28 +00:00
|
|
|
nvtt::OutputOptions outputOptions;
|
2009-03-15 10:18:54 +00:00
|
|
|
outputOptions.setFileName("output.dds");
|
2009-03-05 05:34:28 +00:00
|
|
|
|
|
|
|
nvtt::Context context;
|
2009-03-16 08:37:07 +00:00
|
|
|
nvtt::TexImage image = context.createTexImage();
|
2009-03-05 05:34:28 +00:00
|
|
|
|
2009-03-16 08:37:07 +00:00
|
|
|
image.load("kodim01.png");
|
2009-03-05 05:34:28 +00:00
|
|
|
|
2009-10-12 07:56:02 +00:00
|
|
|
context.outputHeader(image, image.countMipmaps(), compressionOptions, outputOptions);
|
|
|
|
|
2009-03-05 05:34:28 +00:00
|
|
|
float gamma = 2.2;
|
2009-03-16 08:37:07 +00:00
|
|
|
image.toLinear(gamma);
|
2009-03-05 05:34:28 +00:00
|
|
|
|
2009-03-16 08:37:07 +00:00
|
|
|
while (image.buildNextMipmap(nvtt::MipmapFilter_Box))
|
2009-03-05 05:34:28 +00:00
|
|
|
{
|
2009-03-16 08:37:07 +00:00
|
|
|
nvtt::TexImage tmpImage = image;
|
|
|
|
tmpImage.toGamma(gamma);
|
2009-03-07 07:14:00 +00:00
|
|
|
|
2009-10-12 07:56:02 +00:00
|
|
|
context.compress(tmpImage, compressionOptions, outputOptions);
|
|
|
|
// tmpImage.compress(compressionOptions, outputOptions);
|
2009-03-05 05:34:28 +00:00
|
|
|
}
|
|
|
|
|
2009-03-02 07:32:00 +00:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|