2009-03-04 03:31:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ui/PixelFormat.h>
|
2010-02-17 04:43:39 +00:00
|
|
|
#include <hardware/hardware.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2012-02-22 02:56:08 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2009-03-04 03:31:44 +00:00
|
|
|
namespace android {
|
2012-02-22 02:56:08 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2013-07-26 02:24:31 +00:00
|
|
|
ssize_t bytesPerPixel(PixelFormat format) {
|
|
|
|
switch (format) {
|
2013-07-26 21:49:50 +00:00
|
|
|
case PIXEL_FORMAT_RGBA_8888:
|
|
|
|
case PIXEL_FORMAT_RGBX_8888:
|
|
|
|
case PIXEL_FORMAT_BGRA_8888:
|
2014-01-07 23:25:02 +00:00
|
|
|
case PIXEL_FORMAT_sRGB_A_8888:
|
|
|
|
case PIXEL_FORMAT_sRGB_X_8888:
|
2013-07-26 02:24:31 +00:00
|
|
|
return 4;
|
2013-07-26 21:49:50 +00:00
|
|
|
case PIXEL_FORMAT_RGB_888:
|
2013-07-26 02:24:31 +00:00
|
|
|
return 3;
|
2013-07-26 21:49:50 +00:00
|
|
|
case PIXEL_FORMAT_RGB_565:
|
|
|
|
case PIXEL_FORMAT_RGBA_5551:
|
|
|
|
case PIXEL_FORMAT_RGBA_4444:
|
2013-07-26 02:24:31 +00:00
|
|
|
return 2;
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
2013-07-26 02:24:31 +00:00
|
|
|
return BAD_VALUE;
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
2013-07-26 02:24:31 +00:00
|
|
|
ssize_t bitsPerPixel(PixelFormat format) {
|
2010-02-17 04:43:39 +00:00
|
|
|
switch (format) {
|
2013-07-26 21:49:50 +00:00
|
|
|
case PIXEL_FORMAT_RGBA_8888:
|
|
|
|
case PIXEL_FORMAT_RGBX_8888:
|
|
|
|
case PIXEL_FORMAT_BGRA_8888:
|
2013-07-26 02:24:31 +00:00
|
|
|
return 32;
|
2013-07-26 21:49:50 +00:00
|
|
|
case PIXEL_FORMAT_RGB_888:
|
2013-07-26 02:24:31 +00:00
|
|
|
return 24;
|
2013-07-26 21:49:50 +00:00
|
|
|
case PIXEL_FORMAT_RGB_565:
|
|
|
|
case PIXEL_FORMAT_RGBA_5551:
|
|
|
|
case PIXEL_FORMAT_RGBA_4444:
|
2013-07-26 02:24:31 +00:00
|
|
|
return 16;
|
2010-02-17 04:43:39 +00:00
|
|
|
}
|
2013-07-26 02:24:31 +00:00
|
|
|
return BAD_VALUE;
|
2009-03-04 03:31:44 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 02:56:08 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2009-03-04 03:31:44 +00:00
|
|
|
}; // namespace android
|
2012-02-22 02:56:08 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2009-03-04 03:31:44 +00:00
|
|
|
|