| 781 | } |
| 782 | |
| 783 | bool Image::initWithRawData(const uint8_t* data, |
| 784 | ssize_t /*dataLen*/, |
| 785 | int width, |
| 786 | int height, |
| 787 | int /*bitsPerComponent*/, |
| 788 | bool preMulti) |
| 789 | { |
| 790 | bool ret = false; |
| 791 | do |
| 792 | { |
| 793 | AX_BREAK_IF(0 == width || 0 == height); |
| 794 | |
| 795 | _height = height; |
| 796 | _width = width; |
| 797 | _hasPremultipliedAlpha = preMulti; |
| 798 | _pixelFormat = backend::PixelFormat::RGBA8; |
| 799 | |
| 800 | // only RGBA8888 supported |
| 801 | int bytesPerComponent = 4; |
| 802 | _dataLen = height * width * bytesPerComponent; |
| 803 | _data = static_cast<uint8_t*>(malloc(_dataLen)); |
| 804 | AX_BREAK_IF(!_data); |
| 805 | memcpy(_data, data, _dataLen); |
| 806 | |
| 807 | ret = true; |
| 808 | } while (0); |
| 809 | |
| 810 | return ret; |
| 811 | } |
| 812 | |
| 813 | void Image::flipRawData() |
| 814 | { |
no outgoing calls