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

Side by Side Diff: samples/pdfium_test.cc

Issue 1287863002: Remove if checks after new. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> 5 #include <limits.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 char filename[256]; 137 char filename[256];
138 snprintf(filename, sizeof(filename), "%s.%d.ppm", pdf_name, num); 138 snprintf(filename, sizeof(filename), "%s.%d.ppm", pdf_name, num);
139 FILE* fp = fopen(filename, "wb"); 139 FILE* fp = fopen(filename, "wb");
140 if (!fp) 140 if (!fp)
141 return; 141 return;
142 fprintf(fp, "P6\n# PDF test render\n%d %d\n255\n", width, height); 142 fprintf(fp, "P6\n# PDF test render\n%d %d\n255\n", width, height);
143 // Source data is B, G, R, unused. 143 // Source data is B, G, R, unused.
144 // Dest data is R, G, B. 144 // Dest data is R, G, B.
145 char* result = new char[out_len]; 145 char* result = new char[out_len];
146 if (result) { 146 for (int h = 0; h < height; ++h) {
147 for (int h = 0; h < height; ++h) { 147 const char* src_line = buffer + (stride * h);
148 const char* src_line = buffer + (stride * h); 148 char* dest_line = result + (width * h * 3);
149 char* dest_line = result + (width * h * 3); 149 for (int w = 0; w < width; ++w) {
150 for (int w = 0; w < width; ++w) { 150 // R
151 // R 151 dest_line[w * 3] = src_line[(w * 4) + 2];
152 dest_line[w * 3] = src_line[(w * 4) + 2]; 152 // G
153 // G 153 dest_line[(w * 3) + 1] = src_line[(w * 4) + 1];
154 dest_line[(w * 3) + 1] = src_line[(w * 4) + 1]; 154 // B
155 // B 155 dest_line[(w * 3) + 2] = src_line[w * 4];
156 dest_line[(w * 3) + 2] = src_line[w * 4];
157 }
158 } 156 }
159 fwrite(result, out_len, 1, fp);
160 delete [] result;
161 } 157 }
158 fwrite(result, out_len, 1, fp);
159 delete[] result;
162 fclose(fp); 160 fclose(fp);
163 } 161 }
164 162
165 static void WritePng(const char* pdf_name, int num, const void* buffer_void, 163 static void WritePng(const char* pdf_name, int num, const void* buffer_void,
166 int stride, int width, int height) { 164 int stride, int width, int height) {
167 if (!CheckDimensions(stride, width, height)) 165 if (!CheckDimensions(stride, width, height))
168 return; 166 return;
169 167
170 std::vector<unsigned char> png_encoding; 168 std::vector<unsigned char> png_encoding;
171 const unsigned char* buffer = static_cast<const unsigned char*>(buffer_void); 169 const unsigned char* buffer = static_cast<const unsigned char*>(buffer_void);
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 RenderPdf(filename, file_contents, file_length, options); 616 RenderPdf(filename, file_contents, file_length, options);
619 free(file_contents); 617 free(file_contents);
620 } 618 }
621 619
622 FPDF_DestroyLibrary(); 620 FPDF_DestroyLibrary();
623 v8::V8::ShutdownPlatform(); 621 v8::V8::ShutdownPlatform();
624 delete platform; 622 delete platform;
625 623
626 return 0; 624 return 0;
627 } 625 }
OLDNEW
« fpdfsdk/include/javascript/JS_Object.h ('K') | « fpdfsdk/src/pdfwindow/PWL_Wnd.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698