diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-05-14 23:09:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 23:09:03 +0200 |
commit | 00949f0c5fcc6a4f8382a4a97d5591fd9ec380f8 (patch) | |
tree | 2b1c31f45add24085b64425ce440f577424c16a1 /modules/jpg | |
parent | 5046f666a1181675b39f156c38346525dc1c444e (diff) | |
parent | 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 (diff) |
Merge pull request #38738 from akien-mga/cause-we-never-go-out-of-style
Style: Remove new line at block start, enforce line between functions, enforce braces in if and loop blocks
Diffstat (limited to 'modules/jpg')
-rw-r--r-- | modules/jpg/image_loader_jpegd.cpp | 16 | ||||
-rw-r--r-- | modules/jpg/image_loader_jpegd.h | 1 | ||||
-rw-r--r-- | modules/jpg/register_types.cpp | 2 |
3 files changed, 7 insertions, 12 deletions
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp index 1a2afeb5b9..9c7ace5cf2 100644 --- a/modules/jpg/image_loader_jpegd.cpp +++ b/modules/jpg/image_loader_jpegd.cpp @@ -37,7 +37,6 @@ #include <string.h> Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p_buffer_len) { - jpgd::jpeg_decoder_mem_stream mem_stream(p_buffer, p_buffer_len); jpgd::jpeg_decoder decoder(&mem_stream); @@ -49,11 +48,13 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p const int image_width = decoder.get_width(); const int image_height = decoder.get_height(); const int comps = decoder.get_num_components(); - if (comps != 1 && comps != 3) + if (comps != 1 && comps != 3) { return ERR_FILE_CORRUPT; + } - if (decoder.begin_decoding() != jpgd::JPGD_SUCCESS) + if (decoder.begin_decoding() != jpgd::JPGD_SUCCESS) { return ERR_FILE_CORRUPT; + } const int dst_bpl = image_width * comps; @@ -91,10 +92,11 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p //all good Image::Format fmt; - if (comps == 1) + if (comps == 1) { fmt = Image::FORMAT_L8; - else + } else { fmt = Image::FORMAT_RGB8; + } p_image->create(image_width, image_height, false, fmt, data); @@ -102,7 +104,6 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p } Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) { - Vector<uint8_t> src_image; int src_image_len = f->get_len(); ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT); @@ -120,13 +121,11 @@ Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force } void ImageLoaderJPG::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("jpg"); p_extensions->push_back("jpeg"); } static Ref<Image> _jpegd_mem_loader_func(const uint8_t *p_png, int p_size) { - Ref<Image> img; img.instance(); Error err = jpeg_load_image_from_buffer(img.ptr(), p_png, p_size); @@ -135,6 +134,5 @@ static Ref<Image> _jpegd_mem_loader_func(const uint8_t *p_png, int p_size) { } ImageLoaderJPG::ImageLoaderJPG() { - Image::_jpg_mem_loader_func = _jpegd_mem_loader_func; } diff --git a/modules/jpg/image_loader_jpegd.h b/modules/jpg/image_loader_jpegd.h index 9ef37ae303..9aebaad9e3 100644 --- a/modules/jpg/image_loader_jpegd.h +++ b/modules/jpg/image_loader_jpegd.h @@ -34,7 +34,6 @@ #include "core/io/image_loader.h" class ImageLoaderJPG : public ImageFormatLoader { - public: virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale); virtual void get_recognized_extensions(List<String> *p_extensions) const; diff --git a/modules/jpg/register_types.cpp b/modules/jpg/register_types.cpp index 61375fef10..b31746f769 100644 --- a/modules/jpg/register_types.cpp +++ b/modules/jpg/register_types.cpp @@ -35,12 +35,10 @@ static ImageLoaderJPG *image_loader_jpg = nullptr; void register_jpg_types() { - image_loader_jpg = memnew(ImageLoaderJPG); ImageLoader::add_image_format_loader(image_loader_jpg); } void unregister_jpg_types() { - memdelete(image_loader_jpg); } |