Minor changes.
This commit is contained in:
parent
1454cbac14
commit
035231a928
@ -145,6 +145,12 @@ void PixelFormatConverter::compress(nvtt::InputFormat inputFormat, nvtt::AlphaMo
|
||||
const uint * src = (const uint *)data + y * srcPitch;
|
||||
const float * fsrc = (const float *)data + y * srcPitch;
|
||||
|
||||
if (inputFormat == nvtt::InputFormat_BGRA_8UB && compressionOptions.pixelType == nvtt::PixelType_UnsignedNorm && bitCount == 32 && rmask == 0xFF0000 && gmask == 0xFF00 && bmask == 0xFF && amask == 0xFF000000)
|
||||
{
|
||||
convert_to_a8r8g8b8(src, dst, w);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8 * ptr = dst;
|
||||
|
||||
for (uint x = 0; x < w; x++)
|
||||
@ -219,6 +225,7 @@ void PixelFormatConverter::compress(nvtt::InputFormat inputFormat, nvtt::AlphaMo
|
||||
{
|
||||
*(dst + x) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (outputOptions.outputHandler != NULL)
|
||||
{
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "InputOptions.h"
|
||||
#include "CompressionOptions.h"
|
||||
#include "OutputOptions.h"
|
||||
#include "TexImage.h"
|
||||
|
||||
#include "CompressorDXT.h"
|
||||
#include "CompressorRGB.h"
|
||||
@ -334,10 +335,16 @@ bool Compressor::outputHeader(const TexImage & tex, int mipmapCount, const Compr
|
||||
|
||||
bool Compressor::compress(const TexImage & tex, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const
|
||||
{
|
||||
#pragma message(NV_FILE_LINE "TODO: Implement TexImage compress api")
|
||||
// @@ Decide whether to change the swizzling of FloatImage.
|
||||
|
||||
// @@ Convert to fixed point and call compress2D for each face.
|
||||
foreach(i, tex.m->imageArray) {
|
||||
FloatImage * image = tex.m->imageArray[i];
|
||||
if (!m.compress2D(InputFormat_RGBA_32F, tex.m->alphaMode, image->width(), image->height(), image->channel(0), compressionOptions.m, outputOptions.m)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Estimate the size of compressing the given texture.
|
||||
|
@ -246,7 +246,7 @@ int TexImage::countMipmaps() const
|
||||
|
||||
float TexImage::alphaTestCoverage(float alphaRef/*= 0.5*/) const
|
||||
{
|
||||
int imageCount = 0.0f;
|
||||
int imageCount = 0;
|
||||
float coverage = 0.0f;
|
||||
|
||||
foreach (i, m->imageArray)
|
||||
|
@ -26,18 +26,20 @@
|
||||
|
||||
#include "nvtt.h"
|
||||
|
||||
#include <nvcore/Array.h>
|
||||
#include <nvcore/RefCounted.h>
|
||||
#include <nvcore/Ptr.h>
|
||||
#include "nvcore/Array.h"
|
||||
#include "nvcore/RefCounted.h"
|
||||
#include "nvcore/Ptr.h"
|
||||
|
||||
#include <nvimage/Image.h>
|
||||
#include <nvimage/FloatImage.h>
|
||||
#include "nvimage/Image.h"
|
||||
#include "nvimage/FloatImage.h"
|
||||
|
||||
namespace nvtt
|
||||
{
|
||||
|
||||
struct TexImage::Private : public nv::RefCounted
|
||||
{
|
||||
void operator=(const Private &);
|
||||
public:
|
||||
Private()
|
||||
{
|
||||
type = TextureType_2D;
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "CudaUtils.h"
|
||||
|
||||
#include <nvcore/Debug.h>
|
||||
#include <nvcore/Utils.h>
|
||||
#include <nvmath/Color.h>
|
||||
#include <nvimage/Image.h>
|
||||
#include <nvimage/ColorBlock.h>
|
||||
@ -35,6 +34,7 @@
|
||||
#include <nvtt/QuickCompressDXT.h>
|
||||
#include <nvtt/OptimalCompressDXT.h>
|
||||
|
||||
|
||||
#if defined HAVE_CUDA
|
||||
#include <cuda_runtime_api.h>
|
||||
#endif
|
||||
|
@ -456,6 +456,7 @@ namespace nvtt
|
||||
private:
|
||||
void detach();
|
||||
|
||||
friend struct Compressor;
|
||||
struct Private;
|
||||
Private * m;
|
||||
};
|
||||
|
@ -23,11 +23,13 @@
|
||||
|
||||
#include <nvtt/nvtt.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h> // EXIT_SUCCESS, EXIT_FAILURE
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2) return EXIT_FAILURE;
|
||||
|
||||
nvtt::CompressionOptions compressionOptions;
|
||||
compressionOptions.setFormat(nvtt::Format_BC1);
|
||||
|
||||
@ -37,20 +39,23 @@ int main(int argc, char *argv[])
|
||||
nvtt::Context context;
|
||||
nvtt::TexImage image = context.createTexImage();
|
||||
|
||||
image.load("kodim01.png");
|
||||
image.load(argv[1]);
|
||||
|
||||
context.outputHeader(image, image.countMipmaps(), compressionOptions, outputOptions);
|
||||
|
||||
float gamma = 2.2;
|
||||
float gamma = 2.2f;
|
||||
image.toLinear(gamma);
|
||||
|
||||
float coverage = image.alphaTestCoverage();
|
||||
|
||||
while (image.buildNextMipmap(nvtt::MipmapFilter_Box))
|
||||
{
|
||||
nvtt::TexImage tmpImage = image;
|
||||
tmpImage.toGamma(gamma);
|
||||
|
||||
tmpImage.scaleAlphaToCoverage(coverage);
|
||||
|
||||
context.compress(tmpImage, compressionOptions, outputOptions);
|
||||
// tmpImage.compress(compressionOptions, outputOptions);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -169,6 +169,7 @@ int main(int argc, char *argv[])
|
||||
nv::FloatImage fimage(&image);
|
||||
fimage.toLinear(0, 3, gamma);
|
||||
|
||||
#if 0
|
||||
nv::AutoPtr<nv::FloatImage> fresult(fimage.resize(*filter, uint(image.width() * scale), uint(image.height() * scale), wrapMode));
|
||||
|
||||
nv::AutoPtr<nv::Image> result(fresult->createImageGammaCorrect(gamma));
|
||||
@ -176,7 +177,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
nv::StdOutputStream stream(output);
|
||||
nv::ImageIO::save(output, stream, result.ptr());
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user