浏览代码

Allow setting forward matrix 2

Kristian Vos 2 周之前
父节点
当前提交
b78bc308e7
共有 3 个文件被更改,包括 28 次插入3 次删除
  1. 3 0
      include/libdng.h
  2. 24 3
      src/libdng.c
  3. 1 0
      tests/check_dng.c

+ 3 - 0
include/libdng.h

@@ -169,6 +169,9 @@ libdng_set_color_matrix_2(libdng_info *dng, float v1, float v2, float v3, float
 EXPORT int
 libdng_set_forward_matrix_1(libdng_info *dng, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float v8, float v9);
 
+EXPORT int
+libdng_set_forward_matrix_2(libdng_info *dng, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float v8, float v9);
+
 EXPORT int
 libdng_write(libdng_info *dng, const char *path, unsigned int width, unsigned int height, const uint8_t *data,
 	size_t length);

+ 24 - 3
src/libdng.c

@@ -43,6 +43,7 @@ libdng_new(libdng_info *dng)
 		dng->color_matrix_1[i] = 0.0f;
 		dng->color_matrix_2[i] = 0.0f;
 		dng->forward_matrix_1[i] = 0.0f;
+		dng->forward_matrix_2[i] = 0.0f;
 	}
 	dng->color_matrix_1[0] = 1.0f;
 	dng->color_matrix_1[4] = 1.0f;
@@ -306,7 +307,7 @@ libdng_set_color_matrix_1(libdng_info *dng, float v1, float v2, float v3, float
 {
 	if (dng == NULL)
 		return 0;
-	
+
 	dng->color_matrix_1[0] = v1;
 	dng->color_matrix_1[1] = v2;
 	dng->color_matrix_1[2] = v3;
@@ -325,7 +326,7 @@ libdng_set_color_matrix_2(libdng_info *dng, float v1, float v2, float v3, float
 {
 	if (dng == NULL)
 		return 0;
-	
+
 	dng->color_matrix_2[0] = v1;
 	dng->color_matrix_2[1] = v2;
 	dng->color_matrix_2[2] = v3;
@@ -344,7 +345,7 @@ libdng_set_forward_matrix_1(libdng_info *dng, float v1, float v2, float v3, floa
 {
 	if (dng == NULL)
 		return 0;
-	
+
 	dng->forward_matrix_1[0] = v1;
 	dng->forward_matrix_1[1] = v2;
 	dng->forward_matrix_1[2] = v3;
@@ -358,6 +359,25 @@ libdng_set_forward_matrix_1(libdng_info *dng, float v1, float v2, float v3, floa
 	return 1;
 }
 
+int
+libdng_set_forward_matrix_2(libdng_info *dng, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float v8, float v9)
+{
+	if (dng == NULL)
+		return 0;
+
+	dng->forward_matrix_2[0] = v1;
+	dng->forward_matrix_2[1] = v2;
+	dng->forward_matrix_2[2] = v3;
+	dng->forward_matrix_2[3] = v4;
+	dng->forward_matrix_2[4] = v5;
+	dng->forward_matrix_2[5] = v6;
+	dng->forward_matrix_2[6] = v7;
+	dng->forward_matrix_2[7] = v8;
+	dng->forward_matrix_2[8] = v9;
+
+	return 1;
+}
+
 int
 libdng_write(libdng_info *dng, const char *path, unsigned int width, unsigned int height, const uint8_t *data,
 	size_t length)
@@ -410,6 +430,7 @@ libdng_write_with_thumbnail(libdng_info *dng, const char *path, unsigned int wid
 	TIFFSetField(tif, DNGTAG_COLOR_MATRIX_1, 9, dng->color_matrix_1);
 	TIFFSetField(tif, DNGTAG_COLOR_MATRIX_2, 9, dng->color_matrix_2);
 	TIFFSetField(tif, DNGTAG_FORWARD_MATRIX_1, 9, dng->forward_matrix_1);
+	TIFFSetField(tif, DNGTAG_FORWARD_MATRIX_2, 9, dng->forward_matrix_2);
 	TIFFSetField(tif, DNGTAG_ASSHOTNEUTRAL, 3, dng->neutral);
 	TIFFSetField(tif, DNGTAG_ANALOGBALANCE, 3, dng->analogbalance);
 

+ 1 - 0
tests/check_dng.c

@@ -54,6 +54,7 @@ TEST generate_simple_dng(void)
 		ASSERT_EQm("Set color matrix 1", 1, libdng_set_color_matrix_1(&info, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f));
 		ASSERT_EQm("Set color matrix 2", 1, libdng_set_color_matrix_2(&info, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f));
 		ASSERT_EQm("Set forward matrix 1", 1, libdng_set_forward_matrix_1(&info, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f));
+		ASSERT_EQm("Set forward matrix 2", 1, libdng_set_forward_matrix_2(&info, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f));
 	uint8_t *data = malloc(1280 * 720);
 		ASSERT_EQm("Write DNG", 1, libdng_write(&info, "test.dng", 1280, 720, data, 1280 * 720));
 	free(data);