SkColorTable.cpp 609 B

1234567891011121314151617181920212223
  1. /*
  2. * Copyright 2009 The Android Open Source Project
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "include/private/SkMalloc.h"
  8. #include "src/codec/SkColorTable.h"
  9. SkColorTable::SkColorTable(const SkPMColor colors[], int count) {
  10. SkASSERT(0 == count || colors);
  11. SkASSERT(count >= 0 && count <= 256);
  12. fCount = count;
  13. fColors = reinterpret_cast<SkPMColor*>(sk_malloc_throw(count * sizeof(SkPMColor)));
  14. memcpy(fColors, colors, count * sizeof(SkPMColor));
  15. }
  16. SkColorTable::~SkColorTable() {
  17. sk_free(fColors);
  18. }