Skip to content

Commit

Permalink
branch 2.09-bugfixes: changed 'long int' to 'uint64_t' because 'long …
Browse files Browse the repository at this point in the history
…int' is a 32-bit integer for mingw compiller.
  • Loading branch information
buddhi1980 committed Nov 3, 2016
1 parent 04570c1 commit d07f4db
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions mandelbulber2/src/file_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ void ImageFileSaveEXR::SaveImage()
void ImageFileSavePNG::SavePNG(
QString filename, cImage *image, structSaveImageChannel imageChannel, bool appendAlpha)
{
long int width = image->GetWidth();
long int height = image->GetHeight();
uint64_t width = image->GetWidth();
uint64_t height = image->GetHeight();

/* create file */
FILE *fp = fopen(filename.toLocal8Bit().constData(), "wb");
Expand Down Expand Up @@ -308,7 +308,7 @@ void ImageFileSavePNG::SavePNG(

row_pointers = new png_bytep[height];

long int pixelSize = qualitySizeByte;
uint64_t pixelSize = qualitySizeByte;

switch (imageChannel.contentType)
{
Expand Down Expand Up @@ -357,23 +357,23 @@ void ImageFileSavePNG::SavePNG(
break;
}

for (long int y = 0; y < height; y++)
for (uint64_t y = 0; y < height; y++)
{
row_pointers[y] = (png_byte *)&directPointer[y * width * pixelSize];
}
}
else
{
colorPtr = new char[(unsigned long int)width * height * pixelSize];
colorPtr = new char[(uint64_t)width * height * pixelSize];

// calculate min / max values from zbuffer range
float minZ = 1.0e50;
float maxZ = 0.0;
if (imageChannel.contentType == IMAGE_CONTENT_ZBUFFER)
{
float *zbuffer = image->GetZBufferPtr();
unsigned long int size = width * height;
for (unsigned long int i = 0; i < size; i++)
uint64_t size = width * height;
for (uint64_t i = 0; i < size; i++)
{
float z = zbuffer[i];
if (z > maxZ && z < 1e19) maxZ = z;
Expand All @@ -382,11 +382,11 @@ void ImageFileSavePNG::SavePNG(
}
double kZ = log(maxZ / minZ);

for (long int y = 0; y < height; y++)
for (uint64_t y = 0; y < height; y++)
{
for (long int x = 0; x < width; x++)
for (uint64_t x = 0; x < width; x++)
{
unsigned long int ptr = (x + y * width) * pixelSize;
uint64_t ptr = (x + y * width) * pixelSize;
switch (imageChannel.contentType)
{
case IMAGE_CONTENT_COLOR:
Expand Down Expand Up @@ -466,10 +466,10 @@ void ImageFileSavePNG::SavePNG(
}

// png_write_image(png_ptr, row_pointers);
long int chunkSize = 100;
for (long int r = 0; r < height; r += chunkSize)
uint64_t chunkSize = 100;
for (uint64_t r = 0; r < height; r += chunkSize)
{
long int leftToWrite = height - r;
uint64_t leftToWrite = height - r;
png_write_rows(png_ptr, (png_bytepp)&row_pointers[r], min(leftToWrite, chunkSize));
/* TODO: make SavePNG private non static and rewrite direct accesses to static function
emit updateProgressAndStatus(getJobName(),
Expand Down Expand Up @@ -801,15 +801,15 @@ void ImageFileSaveEXR::SaveEXR(

int pixelSize = sizeof(tsRGB<half>);
if (imfQuality == Imf::FLOAT) pixelSize = sizeof(tsRGB<float>);
char *buffer = new char[(unsigned long int)width * height * pixelSize];
char *buffer = new char[(uint64_t)width * height * pixelSize];
tsRGB<half> *halfPointer = (tsRGB<half> *)buffer;
tsRGB<float> *floatPointer = (tsRGB<float> *)buffer;

for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned long int ptr = (x + y * width);
uint64_t ptr = (x + y * width);
if (imfQuality == Imf::FLOAT)
{
sRGB16 pixel = image->GetPixelImage16(x, y);
Expand Down Expand Up @@ -848,15 +848,15 @@ void ImageFileSaveEXR::SaveEXR(

int pixelSize = sizeof(half);
if (imfQuality == Imf::FLOAT) pixelSize = sizeof(float);
char *buffer = new char[(unsigned long int)width * height * pixelSize];
char *buffer = new char[(uint64_t)width * height * pixelSize];
half *halfPointer = (half *)buffer;
float *floatPointer = (float *)buffer;

for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned long int ptr = x + y * width;
uint64_t ptr = x + y * width;

if (imfQuality == Imf::FLOAT)
{
Expand Down Expand Up @@ -893,14 +893,14 @@ void ImageFileSaveEXR::SaveEXR(
else
{
int pixelSize = sizeof(half);
char *buffer = new char[(unsigned long int)width * height * pixelSize];
char *buffer = new char[(uint64_t)width * height * pixelSize];
half *halfPointer = (half *)buffer;

for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned long int ptr = x + y * width;
uint64_t ptr = x + y * width;
halfPointer[ptr] = image->GetPixelZBuffer(x, y);
}
}
Expand All @@ -922,15 +922,15 @@ void ImageFileSaveEXR::SaveEXR(

int pixelSize = sizeof(tsRGB<half>);
if (imfQuality == Imf::FLOAT) pixelSize = sizeof(tsRGB<float>);
char *buffer = new char[(unsigned long int)width * height * pixelSize];
char *buffer = new char[(uint64_t)width * height * pixelSize];
tsRGB<half> *halfPointer = (tsRGB<half> *)buffer;
tsRGB<float> *floatPointer = (tsRGB<float> *)buffer;

for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
unsigned long int ptr = (x + y * width);
uint64_t ptr = (x + y * width);
sRGBfloat pixel = image->GetPixelNormal(x, y);
if (imfQuality == Imf::FLOAT)
{
Expand Down Expand Up @@ -965,8 +965,8 @@ void ImageFileSaveEXR::SaveEXR(
bool ImageFileSaveTIFF::SaveTIFF(
QString filename, cImage *image, structSaveImageChannel imageChannel, bool appendAlpha)
{
long int width = image->GetWidth();
long int height = image->GetHeight();
uint64_t width = image->GetWidth();
uint64_t height = image->GetHeight();

TIFF *tiff = TIFFOpen(filename.toLocal8Bit().constData(), "w");
if (!tiff)
Expand Down Expand Up @@ -1024,8 +1024,8 @@ bool ImageFileSaveTIFF::SaveTIFF(
TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, sampleFormat);

long int pixelSize = samplesPerPixel * qualitySize / 8;
char *colorPtr = new char[(unsigned long int)width * height * pixelSize];
uint64_t pixelSize = samplesPerPixel * qualitySize / 8;
char *colorPtr = new char[(uint64_t)width * height * pixelSize];

// calculate min / max values from zbuffer range
float minZ = 1.0e50;
Expand All @@ -1034,20 +1034,20 @@ bool ImageFileSaveTIFF::SaveTIFF(
if (imageChannel.contentType == IMAGE_CONTENT_ZBUFFER)
{
float *zbuffer = image->GetZBufferPtr();
unsigned long int size = width * height;
for (unsigned long int i = 0; i < size; i++)
uint64_t size = width * height;
for (uint64_t i = 0; i < size; i++)
{
float z = zbuffer[i];
if (z > maxZ && z < 1e19) maxZ = z;
if (z < minZ) minZ = z;
}
rangeZ = maxZ - minZ;
}
for (int y = 0; y < height; y++)
for (uint64_t y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
for (uint64_t x = 0; x < width; x++)
{
unsigned long int ptr = (x + y * width) * pixelSize;
uint64_t ptr = (x + y * width) * pixelSize;
switch (imageChannel.contentType)
{
case IMAGE_CONTENT_COLOR:
Expand Down

0 comments on commit d07f4db

Please sign in to comment.