Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-05-19 05:40:37 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-05-19 05:40:37 +0400
commitdfcd01553536d63dab1037d0ea289b9d9d90c39c (patch)
tree089cf7b605457c8d565f1e1a3c82558210c5e87d /source/blender/imbuf/intern
parent31471f644cb9d9c3b88da1977705724649482a82 (diff)
parentc04f9b779c4384f3cc6961b2ed54456bdab14f43 (diff)
Merged changes in the trunk up to revision 36757.
Diffstat (limited to 'source/blender/imbuf/intern')
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c9
-rw-r--r--source/blender/imbuf/intern/cineon/cineon_dpx.c9
-rw-r--r--source/blender/imbuf/intern/cineon/cineonfile.h13
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.c4
-rw-r--r--source/blender/imbuf/intern/cineon/logmemfile.c2
-rw-r--r--source/blender/imbuf/intern/dds/DirectDrawSurface.cpp2
-rw-r--r--source/blender/imbuf/intern/filter.c2
-rw-r--r--source/blender/imbuf/intern/png.c18
-rw-r--r--source/blender/imbuf/intern/tiff.c39
9 files changed, 67 insertions, 31 deletions
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index a8b9e21331d..59772771f3b 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -84,17 +84,13 @@ void imb_freerectfloatImBuf(ImBuf *ibuf)
void imb_freerectImBuf(ImBuf *ibuf)
{
if(ibuf==NULL) return;
-
- if(ibuf->crect)
- MEM_freeN(ibuf->crect);
if(ibuf->rect && (ibuf->mall & IB_rect))
MEM_freeN(ibuf->rect);
+ ibuf->rect= NULL;
imb_freemipmapImBuf(ibuf);
-
- ibuf->rect= NULL;
- ibuf->crect= NULL;
+
ibuf->mall &= ~IB_rect;
}
@@ -346,6 +342,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar d, unsigned int flag
ibuf->depth= d;
ibuf->ftype= TGA;
ibuf->channels= 4; /* float option, is set to other values when buffers get assigned */
+ ibuf->ppm[0]= ibuf->ppm[1]= 150.0 / 0.0254; /* 150dpi -> pixels-per-meter */
if(flags & IB_rect) {
if(imb_addrectImBuf(ibuf)==FALSE) {
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c
index 504817b263f..8df2a9f6985 100644
--- a/source/blender/imbuf/intern/cineon/cineon_dpx.c
+++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c
@@ -44,6 +44,7 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "IMB_filetype.h"
#include "BKE_global.h"
@@ -192,7 +193,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
return 1;
}
-short imb_savecineon(struct ImBuf *buf, const char *myfile, int flags)
+int imb_savecineon(struct ImBuf *buf, const char *myfile, int flags)
{
return imb_save_dpx_cineon(buf, myfile, 1, flags);
}
@@ -203,14 +204,14 @@ int imb_is_cineon(unsigned char *buf)
return cineonIsMemFileCineon(buf);
}
-ImBuf *imb_loadcineon(unsigned char *mem, int size, int flags)
+ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags)
{
if(imb_is_cineon(mem))
return imb_load_dpx_cineon(mem, 1, size, flags);
return NULL;
}
-short imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags)
+int imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags)
{
return imb_save_dpx_cineon(buf, myfile, 0, flags);
}
@@ -220,7 +221,7 @@ int imb_is_dpx(unsigned char *buf)
return dpxIsMemFileCineon(buf);
}
-ImBuf *imb_loaddpx(unsigned char *mem, int size, int flags)
+ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags)
{
if(imb_is_dpx(mem))
return imb_load_dpx_cineon(mem, 0, size, flags);
diff --git a/source/blender/imbuf/intern/cineon/cineonfile.h b/source/blender/imbuf/intern/cineon/cineonfile.h
index 31aa56f560c..896e0af65b3 100644
--- a/source/blender/imbuf/intern/cineon/cineonfile.h
+++ b/source/blender/imbuf/intern/cineon/cineonfile.h
@@ -126,19 +126,6 @@ typedef struct {
ASCII reserved[740];
} CineonMPISpecificInformation;
-#if 0
-/* create CineonFile from data in header */
-/* return 0 for OK */
-int readCineonGenericHeader(CineonFile* cineon, CineonGenericHeader* header);
-
-/* create header from data in CineonFile */
-int initCineonGenericHeader(
- CineonFile* cineon, CineonGenericHeader* header, const char* imagename);
-
-/* Note: dump routine assumes network byte order */
-void dumpCineonGenericHeader(CineonGenericHeader* header);
-#endif
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c
index fdcd3491af1..922cfcf9629 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.c
+++ b/source/blender/imbuf/intern/cineon/cineonlib.c
@@ -276,7 +276,7 @@ dumpCineonOriginationInfo(CineonOriginationInformation* originInfo) {
d_printf("Input device gamma %f\n", ntohf(originInfo->input_device_gamma));
}
-int
+static int
initCineonGenericHeader(CineonFile* cineon, CineonGenericHeader* header, const char* imagename) {
fillCineonFileInfo(cineon, &header->fileInfo, imagename);
@@ -287,7 +287,7 @@ initCineonGenericHeader(CineonFile* cineon, CineonGenericHeader* header, const c
return 0;
}
-void
+static void
dumpCineonGenericHeader(CineonGenericHeader* header) {
dumpCineonFileInfo(&header->fileInfo);
dumpCineonImageInfo(&header->imageInfo);
diff --git a/source/blender/imbuf/intern/cineon/logmemfile.c b/source/blender/imbuf/intern/cineon/logmemfile.c
index 6347eb5fdf9..d3a32774efd 100644
--- a/source/blender/imbuf/intern/cineon/logmemfile.c
+++ b/source/blender/imbuf/intern/cineon/logmemfile.c
@@ -27,6 +27,8 @@
#include "logImageCore.h"
+#include "logmemfile.h" /* own include */
+
int logimage_fseek(void* logfile, intptr_t offsett, int origin)
{
struct _Log_Image_File_t_ *file = (struct _Log_Image_File_t_*) logfile;
diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
index ceac1d2ae18..971658ff482 100644
--- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
+++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
@@ -980,7 +980,7 @@ bool DirectDrawSurface::hasAlpha() const
{
if (header.hasDX10Header())
{
-#pragma NV_MESSAGE("TODO: Update hasAlpha to handle all DX10 formats.")
+ /* TODO: Update hasAlpha to handle all DX10 formats. */
return
header.header10.dxgiFormat == DXGI_FORMAT_BC1_UNORM ||
header.header10.dxgiFormat == DXGI_FORMAT_BC2_UNORM ||
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c
index 2821ba2a361..16fb1fdf4aa 100644
--- a/source/blender/imbuf/intern/filter.c
+++ b/source/blender/imbuf/intern/filter.c
@@ -437,7 +437,7 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter)
hbuf= ibuf->mipmap[curmap];
hbuf->miplevel= curmap+1;
- if(!hbuf || (hbuf->x == 1 && hbuf->y == 1))
+ if(!hbuf || (hbuf->x <= 2 && hbuf->y <= 2))
break;
curmap++;
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index 200ff0af9af..6b6dcdb88af 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -257,6 +257,10 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
}
+ if(ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) {
+ png_set_pHYs(png_ptr, info_ptr, (unsigned int)(ibuf->ppm[0] + 0.5), (unsigned int)(ibuf->ppm[1] + 0.5), PNG_RESOLUTION_METER);
+ }
+
// write the file header information
png_write_info(png_ptr, info_ptr);
@@ -384,7 +388,19 @@ struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags)
if (ibuf) {
ibuf->ftype = PNG;
ibuf->profile = IB_PROFILE_SRGB;
- } else {
+
+ if (png_get_valid (png_ptr, info_ptr, PNG_INFO_pHYs)) {
+ int unit_type;
+ unsigned int xres, yres;
+
+ if(png_get_pHYs(png_ptr, info_ptr, &xres, &yres, &unit_type))
+ if(unit_type == PNG_RESOLUTION_METER) {
+ ibuf->ppm[0]= xres;
+ ibuf->ppm[1]= yres;
+ }
+ }
+ }
+ else {
printf("Couldn't allocate memory for PNG image\n");
}
diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c
index 67d20d56466..36130aa0dbf 100644
--- a/source/blender/imbuf/intern/tiff.c
+++ b/source/blender/imbuf/intern/tiff.c
@@ -354,6 +354,25 @@ static void scanline_separate_32bit(float *rectf, float *fbuf, int scanline_w, i
rectf[i*4 + chan] = fbuf[i];
}
+static void imb_read_tiff_resolution(ImBuf *ibuf, TIFF *image)
+{
+ uint16 unit;
+ float xres;
+ float yres;
+
+ TIFFGetFieldDefaulted(image, TIFFTAG_RESOLUTIONUNIT, &unit);
+ TIFFGetFieldDefaulted(image, TIFFTAG_XRESOLUTION, &xres);
+ TIFFGetFieldDefaulted(image, TIFFTAG_YRESOLUTION, &yres);
+
+ if(unit == RESUNIT_CENTIMETER) {
+ ibuf->ppm[0]= (double)xres * 100.0;
+ ibuf->ppm[1]= (double)yres * 100.0;
+ }
+ else {
+ ibuf->ppm[0]= (double)xres / 0.0254;
+ ibuf->ppm[1]= (double)yres / 0.0254;
+ }
+}
/*
* Use the libTIFF scanline API to read a TIFF image.
@@ -369,10 +388,13 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul)
int ib_flag=0, row, chan;
float *fbuf=NULL;
unsigned short *sbuf=NULL;
-
+
TIFFGetField(image, TIFFTAG_BITSPERSAMPLE, &bitspersample);
TIFFGetField(image, TIFFTAG_SAMPLESPERPIXEL, &spp); /* number of 'channels' */
TIFFGetField(image, TIFFTAG_PLANARCONFIG, &config);
+
+ imb_read_tiff_resolution(ibuf, image);
+
scanline = TIFFScanlineSize(image);
if (bitspersample == 32) {
@@ -658,6 +680,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
unsigned char *from = NULL, *to = NULL;
unsigned short *pixels16 = NULL, *to16 = NULL;
float *fromf = NULL;
+ float xres, yres;
int x, y, from_i, to_i, i;
int extraSampleTypes[1] = { EXTRASAMPLE_ASSOCALPHA };
@@ -783,8 +806,18 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags)
TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE);
TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
- TIFFSetField(image, TIFFTAG_XRESOLUTION, 150.0);
- TIFFSetField(image, TIFFTAG_YRESOLUTION, 150.0);
+
+
+ if(ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) {
+ xres= (float)(ibuf->ppm[0] * 0.0254);
+ yres= (float)(ibuf->ppm[1] * 0.0254);
+ }
+ else {
+ xres= yres= 150.0f;
+ }
+
+ TIFFSetField(image, TIFFTAG_XRESOLUTION, xres);
+ TIFFSetField(image, TIFFTAG_YRESOLUTION, yres);
TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);
if(TIFFWriteEncodedStrip(image, 0,
(bitspersample == 16)? (unsigned char*)pixels16: pixels,