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

Side by Side Diff: base/gfx/jpeg_codec.h

Issue 243076: Move the JPEG and PNG codecs from base/gfx to app/gfx/codec. Move the classes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_GFX_JPEG_CODEC_H_
6 #define BASE_GFX_JPEG_CODEC_H_
7
8 #include <vector>
9
10 class SkBitmap;
11
12 // Interface for encoding/decoding JPEG data. This is a wrapper around libjpeg,
13 // which has an inconvenient interface for callers. This is only used for UI
14 // elements, WebKit has its own more complicated JPEG decoder which handles,
15 // among other things, partially downloaded data.
16 class JPEGCodec {
17 public:
18 enum ColorFormat {
19 // 3 bytes per pixel (packed), in RGB order regardless of endianness.
20 // This is the native JPEG format.
21 FORMAT_RGB,
22
23 // 4 bytes per pixel, in RGBA order in mem regardless of endianness.
24 FORMAT_RGBA,
25
26 // 4 bytes per pixel, in BGRA order in mem regardless of endianness.
27 // This is the default Windows DIB order.
28 FORMAT_BGRA
29 };
30
31 // Encodes the given raw 'input' data, with each pixel being represented as
32 // given in 'format'. The encoded JPEG data will be written into the supplied
33 // vector and true will be returned on success. On failure (false), the
34 // contents of the output buffer are undefined.
35 //
36 // w, h: dimensions of the image
37 // row_byte_width: the width in bytes of each row. This may be greater than
38 // w * bytes_per_pixel if there is extra padding at the end of each row
39 // (often, each row is padded to the next machine word).
40 // quality: an integer in the range 0-100, where 100 is the highest quality.
41 static bool Encode(const unsigned char* input, ColorFormat format,
42 int w, int h, int row_byte_width,
43 int quality, std::vector<unsigned char>* output);
44
45 // Decodes the JPEG data contained in input of length input_size. The
46 // decoded data will be placed in *output with the dimensions in *w and *h
47 // on success (returns true). This data will be written in the'format'
48 // format. On failure, the values of these output variables is undefined.
49 static bool Decode(const unsigned char* input, size_t input_size,
50 ColorFormat format, std::vector<unsigned char>* output,
51 int* w, int* h);
52
53 // Decodes the JPEG data contained in input of length input_size. If
54 // successful, a SkBitmap is created and returned. It is up to the caller
55 // to delete the returned bitmap.
56 static SkBitmap* Decode(const unsigned char* input, size_t input_size);
57 };
58
59 #endif // BASE_GFX_JPEG_CODEC_H_
OLDNEW
« no previous file with comments | « base/gfx/DEPS ('k') | base/gfx/jpeg_codec.cc » ('j') | build/common.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698