Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Unified Diff: core/fpdfdoc/cpvt_color.cpp

Issue 1840413002: Split core/include/fpdfdoc/fpdf_ap.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/cpvt_color.h ('k') | core/fpdfdoc/cpvt_dash.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpvt_color.cpp
diff --git a/core/fpdfdoc/cpvt_color.cpp b/core/fpdfdoc/cpvt_color.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..afeff23e154663840ac4fab2533b31ea73efcc22
--- /dev/null
+++ b/core/fpdfdoc/cpvt_color.cpp
@@ -0,0 +1,51 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fpdfdoc/cpvt_color.h"
+
+#include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h"
+
+// Static.
+CPVT_Color CPVT_Color::ParseColor(const CFX_ByteString& str) {
+ CPDF_SimpleParser syntax(str);
+ if (syntax.FindTagParamFromStart("g", 1))
+ return CPVT_Color(CPVT_Color::kGray, FX_atof(syntax.GetWord()));
+
+ if (syntax.FindTagParamFromStart("rg", 3)) {
+ FX_FLOAT f1 = FX_atof(syntax.GetWord());
+ FX_FLOAT f2 = FX_atof(syntax.GetWord());
+ FX_FLOAT f3 = FX_atof(syntax.GetWord());
+ return CPVT_Color(CPVT_Color::kRGB, f1, f2, f3);
+ }
+ if (syntax.FindTagParamFromStart("k", 4)) {
+ FX_FLOAT f1 = FX_atof(syntax.GetWord());
+ FX_FLOAT f2 = FX_atof(syntax.GetWord());
+ FX_FLOAT f3 = FX_atof(syntax.GetWord());
+ FX_FLOAT f4 = FX_atof(syntax.GetWord());
+ return CPVT_Color(CPVT_Color::kCMYK, f1, f2, f3, f4);
+ }
+ return CPVT_Color(CPVT_Color::kTransparent);
+}
+
+// Static.
+CPVT_Color CPVT_Color::ParseColor(const CPDF_Array& array) {
+ CPVT_Color rt;
+ switch (array.GetCount()) {
+ case 1:
+ rt = CPVT_Color(CPVT_Color::kGray, array.GetFloatAt(0));
+ break;
+ case 3:
+ rt = CPVT_Color(CPVT_Color::kRGB, array.GetFloatAt(0),
+ array.GetFloatAt(1), array.GetFloatAt(2));
+ break;
+ case 4:
+ rt = CPVT_Color(CPVT_Color::kCMYK, array.GetFloatAt(0),
+ array.GetFloatAt(1), array.GetFloatAt(2),
+ array.GetFloatAt(3));
+ break;
+ }
+ return rt;
+}
« no previous file with comments | « core/fpdfdoc/cpvt_color.h ('k') | core/fpdfdoc/cpvt_dash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698