Skip to content

Commit

Permalink
* support encode gray to jpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
lxowalle committed Jun 6, 2024
1 parent ecf69a3 commit 005ca6e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions components/vision/src/maix_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,23 @@ namespace maix::image
if(format == image::FMT_JPEG) // compress
{
switch (_format) {
#ifdef PLATFORM_MAIXCAM
case image::FMT_GRAYSCALE:
{
image::Image *img = nullptr;
if (!mmf_enc_jpg_push_with_quality(0, (uint8_t *)_data, _width, _height, mmf_invert_format_to_mmf(image::FMT_GRAYSCALE), 95)) {
uint8_t *data;
int data_size;
if (!mmf_enc_jpg_pop(0, &data, &data_size)) {
img = new image::Image(_width, _height, format, data, data_size, true);
mmf_enc_jpg_free(0);
}
}
return img;
break;
}
case image::FMT_YVU420SP:
{
#ifdef PLATFORM_MAIXCAM
image::Image *img = nullptr;
if (!mmf_enc_jpg_push_with_quality(0, (uint8_t *)_data, _width, _height, mmf_invert_format_to_mmf(image::FMT_YVU420SP), 95)) {
uint8_t *data;
Expand All @@ -432,9 +446,9 @@ namespace maix::image
}
}
return img;
#endif
break;
}
#endif
default:
{
#ifdef PLATFORM_MAIXCAM
Expand Down

0 comments on commit 005ca6e

Please sign in to comment.