diff options
author | Bo Xu <bo_xu@foxitsoftware.com> | 2014-11-03 18:38:41 -0800 |
---|---|---|
committer | Bo Xu <bo_xu@foxitsoftware.com> | 2014-11-03 18:38:41 -0800 |
commit | 9d9f6c347f56b07ec519c93097066a7eb541263d (patch) | |
tree | 040b7a6aa6618e31fc11500d658b56567fbc89b7 /xfa_test/pdf/number_image_generator.cc | |
parent | 062a0798d91646959e8092a129fbe706534ca387 (diff) | |
download | pdfium-9d9f6c347f56b07ec519c93097066a7eb541263d.tar.xz |
Remove xfa_test for delivery
Diffstat (limited to 'xfa_test/pdf/number_image_generator.cc')
-rw-r--r-- | xfa_test/pdf/number_image_generator.cc | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/xfa_test/pdf/number_image_generator.cc b/xfa_test/pdf/number_image_generator.cc deleted file mode 100644 index 289691513c..0000000000 --- a/xfa_test/pdf/number_image_generator.cc +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "pdf/number_image_generator.h" - -#include "base/logging.h" -#include "base/strings/string_util.h" -#include "pdf/draw_utils.h" -#include "pdf/instance.h" - -namespace chrome_pdf { - -const int kPageNumberSeparator = 0; -const int kPageNumberOriginX = 8; -const int kPageNumberOriginY = 4; - -NumberImageGenerator::NumberImageGenerator(Instance* instance) - : instance_(instance), - device_scale_(1.0f) { -} - -NumberImageGenerator::~NumberImageGenerator() { -} - -void NumberImageGenerator::Configure(const pp::ImageData& number_background, - const std::vector<pp::ImageData>& number_images, float device_scale) { - number_background_ = number_background; - number_images_ = number_images; - device_scale_ = device_scale; -} - -void NumberImageGenerator::GenerateImage( - int page_number, pp::ImageData* image) { - char buffer[12]; - base::snprintf(buffer, sizeof(buffer), "%u", page_number); - int extra_width = 0; - DCHECK(number_images_.size() >= 10); - DCHECK(!number_background_.is_null()); - for (size_t i = 1; i < strlen(buffer); ++i) { - int index = buffer[i] - '0'; - extra_width += number_images_[index].size().width(); - extra_width += static_cast<int>(kPageNumberSeparator * device_scale_); - } - - *image = pp::ImageData( - instance_, - PP_IMAGEDATAFORMAT_BGRA_PREMUL, - pp::Size(number_background_.size().width() + extra_width, - number_background_.size().height()), - false); - - int stretch_point = number_background_.size().width() / 2; - - pp::Rect src_rc(0, 0, stretch_point, number_background_.size().height()); - pp::Rect dest_rc(src_rc); - CopyImage(number_background_, src_rc, image, dest_rc, false); - src_rc.Offset(number_background_.size().width() - stretch_point, 0); - dest_rc.Offset(image->size().width() - stretch_point, 0); - CopyImage(number_background_, src_rc, image, dest_rc, false); - src_rc = pp::Rect(stretch_point, 0, 1, number_background_.size().height()); - dest_rc = src_rc; - dest_rc.set_width(extra_width + 1); - CopyImage(number_background_, src_rc, image, dest_rc, true); - - pp::Point origin(static_cast<int>(kPageNumberOriginX * device_scale_), - static_cast<int>(kPageNumberOriginY * device_scale_)); - for (size_t i = 0; i < strlen(buffer); ++i) { - int index = buffer[i] - '0'; - CopyImage( - number_images_[index], - pp::Rect(pp::Point(), number_images_[index].size()), - image, pp::Rect(origin, number_images_[index].size()), false); - origin += pp::Point( - number_images_[index].size().width() + - static_cast<int>(kPageNumberSeparator * device_scale_), 0); - } -} - -} // namespace chrome_pdf - |