mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #586 from openmv/read_pixels
Remove line_start from read_pixels functions.
This commit is contained in:
commit
eff78c2990
@ -81,15 +81,13 @@ bool bmp_read_geometry(FIL *fp, image_t *img, const char *path, bmp_read_setting
|
||||
}
|
||||
|
||||
// This function reads the pixel values of an image.
|
||||
void bmp_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, bmp_read_settings_t *rs)
|
||||
void bmp_read_pixels(FIL *fp, image_t *img, int n_lines, bmp_read_settings_t *rs)
|
||||
{
|
||||
if (rs->bmp_bpp == 8) {
|
||||
if ((rs->bmp_h < 0) && (rs->bmp_w >= 0) && (img->w == rs->bmp_row_bytes)) {
|
||||
read_data(fp, // Super Fast - Zoom, Zoom!
|
||||
img->pixels + (line_start * img->w),
|
||||
(line_end - line_start) * img->w);
|
||||
read_data(fp, img->pixels, n_lines * img->w);
|
||||
} else {
|
||||
for (int i = line_start; i < line_end; i++) {
|
||||
for (int i = 0; i < n_lines; i++) {
|
||||
for (int j = 0; j < rs->bmp_row_bytes; j++) {
|
||||
uint8_t pixel;
|
||||
read_byte(fp, &pixel);
|
||||
@ -112,7 +110,7 @@ void bmp_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, bmp_re
|
||||
}
|
||||
}
|
||||
} else if (rs->bmp_bpp == 16) {
|
||||
for (int i = line_start; i < line_end; i++) {
|
||||
for (int i = 0; i < n_lines; i++) {
|
||||
for (int j = 0, jj = rs->bmp_row_bytes / 2; j < jj; j++) {
|
||||
uint16_t pixel;
|
||||
read_word(fp, &pixel);
|
||||
@ -135,7 +133,7 @@ void bmp_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, bmp_re
|
||||
}
|
||||
}
|
||||
} else if (rs->bmp_bpp == 24) {
|
||||
for (int i = line_start; i < line_end; i++) {
|
||||
for (int i = 0; i < n_lines; i++) {
|
||||
for (int j = 0, jj = rs->bmp_row_bytes / 3; j < jj; j++) {
|
||||
uint8_t r, g, b;
|
||||
read_byte(fp, &r);
|
||||
@ -173,7 +171,7 @@ void bmp_read(image_t *img, const char *path)
|
||||
file_buffer_on(&fp);
|
||||
bmp_read_geometry(&fp, img, path, &rs);
|
||||
if (!img->pixels) img->pixels = xalloc(img->w * img->h * img->bpp);
|
||||
bmp_read_pixels(&fp, img, 0, img->h, &rs);
|
||||
bmp_read_pixels(&fp, img, img->h, &rs);
|
||||
file_buffer_off(&fp);
|
||||
file_close(&fp);
|
||||
}
|
||||
|
||||
@ -559,14 +559,14 @@ bool imlib_read_geometry(FIL *fp, image_t *img, const char *path, img_read_setti
|
||||
return vflipped;
|
||||
}
|
||||
|
||||
static void imlib_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, img_read_settings_t *rs)
|
||||
static void imlib_read_pixels(FIL *fp, image_t *img, int n_lines, img_read_settings_t *rs)
|
||||
{
|
||||
switch (rs->format) {
|
||||
case FORMAT_BMP:
|
||||
bmp_read_pixels(fp, img, line_start, line_end, &rs->bmp_rs);
|
||||
bmp_read_pixels(fp, img, n_lines, &rs->bmp_rs);
|
||||
break;
|
||||
case FORMAT_PNM:
|
||||
ppm_read_pixels(fp, img, line_start, line_end, &rs->ppm_rs);
|
||||
ppm_read_pixels(fp, img, n_lines, &rs->ppm_rs);
|
||||
break;
|
||||
default: // won't happen
|
||||
break;
|
||||
@ -603,7 +603,7 @@ void imlib_image_operation(image_t *img, const char *path, image_t *other, int s
|
||||
}
|
||||
for (int i=0; i<img->h; i+=temp.h) { // goes past end
|
||||
int lines = IM_MIN(temp.h, img->h-i);
|
||||
imlib_read_pixels(&fp, &temp, 0, lines, &rs);
|
||||
imlib_read_pixels(&fp, &temp, lines, &rs);
|
||||
for (int j=0; j<lines; j++) {
|
||||
if (!vflipped) {
|
||||
op(img, i+j, temp.pixels+(temp.w*temp.bpp*j), data, false);
|
||||
|
||||
@ -1151,11 +1151,11 @@ void imlib_bayer_to_rgb565(image_t *img, int w, int h, int xoffs, int yoffs, uin
|
||||
|
||||
/* Image file functions */
|
||||
void ppm_read_geometry(FIL *fp, image_t *img, const char *path, ppm_read_settings_t *rs);
|
||||
void ppm_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, ppm_read_settings_t *rs);
|
||||
void ppm_read_pixels(FIL *fp, image_t *img, int n_lines, ppm_read_settings_t *rs);
|
||||
void ppm_read(image_t *img, const char *path);
|
||||
void ppm_write_subimg(image_t *img, const char *path, rectangle_t *r);
|
||||
bool bmp_read_geometry(FIL *fp, image_t *img, const char *path, bmp_read_settings_t *rs);
|
||||
void bmp_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, bmp_read_settings_t *rs);
|
||||
void bmp_read_pixels(FIL *fp, image_t *img, int n_lines, bmp_read_settings_t *rs);
|
||||
void bmp_read(image_t *img, const char *path);
|
||||
void bmp_write_subimg(image_t *img, const char *path, rectangle_t *r);
|
||||
bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc);
|
||||
|
||||
@ -69,10 +69,10 @@ void ppm_read_geometry(FIL *fp, image_t *img, const char *path, ppm_read_setting
|
||||
}
|
||||
|
||||
// This function reads the pixel values of an image.
|
||||
void ppm_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, ppm_read_settings_t *rs)
|
||||
void ppm_read_pixels(FIL *fp, image_t *img, int n_lines, ppm_read_settings_t *rs)
|
||||
{
|
||||
if (rs->ppm_fmt == '2') {
|
||||
for (int i = line_start; i < line_end; i++) {
|
||||
for (int i = 0; i < n_lines; i++) {
|
||||
for (int j = 0; j < img->w; j++) {
|
||||
uint32_t pixel;
|
||||
read_int(fp, &pixel, rs);
|
||||
@ -80,7 +80,7 @@ void ppm_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, ppm_re
|
||||
}
|
||||
}
|
||||
} else if (rs->ppm_fmt == '3') {
|
||||
for (int i = line_start; i < line_end; i++) {
|
||||
for (int i = 0; i < n_lines; i++) {
|
||||
for (int j = 0; j < img->w; j++) {
|
||||
uint32_t r, g, b;
|
||||
read_int(fp, &r, rs);
|
||||
@ -92,11 +92,9 @@ void ppm_read_pixels(FIL *fp, image_t *img, int line_start, int line_end, ppm_re
|
||||
}
|
||||
}
|
||||
} else if (rs->ppm_fmt == '5') {
|
||||
read_data(fp, // Super Fast - Zoom, Zoom!
|
||||
img->pixels + (line_start * img->w),
|
||||
(line_end - line_start) * img->w);
|
||||
read_data(fp, img->pixels, n_lines * img->w);
|
||||
} else if (rs->ppm_fmt == '6') {
|
||||
for (int i = line_start; i < line_end; i++) {
|
||||
for (int i = 0; i < n_lines; i++) {
|
||||
for (int j = 0; j < img->w; j++) {
|
||||
uint8_t r, g, b;
|
||||
read_byte(fp, &r);
|
||||
@ -118,7 +116,7 @@ void ppm_read(image_t *img, const char *path)
|
||||
file_buffer_on(&fp);
|
||||
ppm_read_geometry(&fp, img, path, &rs);
|
||||
if (!img->pixels) img->pixels = xalloc(img->w * img->h * img->bpp);
|
||||
ppm_read_pixels(&fp, img, 0, img->h, &rs);
|
||||
ppm_read_pixels(&fp, img, img->h, &rs);
|
||||
file_buffer_off(&fp);
|
||||
file_close(&fp);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user