Lines Matching refs:info

32 static int bmp_read_info(gdIOCtxPtr infile, bmp_info_t *info);
33 static int bmp_read_windows_v3_info(gdIOCtxPtr infile, bmp_info_t *info);
34 static int bmp_read_os2_v1_info(gdIOCtxPtr infile, bmp_info_t *info);
35 static int bmp_read_os2_v2_info(gdIOCtxPtr infile, bmp_info_t *info);
37 static int bmp_read_direct(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header);
38 static int bmp_read_1bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header);
39 static int bmp_read_4bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header);
40 static int bmp_read_8bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header);
41 static int bmp_read_rle(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info);
439 bmp_info_t *info; in gdImageCreateFromBmpCtx() local
457 if (!(info = (bmp_info_t *)gdCalloc(1, sizeof(bmp_info_t)))) { in gdImageCreateFromBmpCtx()
462 if (bmp_read_info(infile, info)) { in gdImageCreateFromBmpCtx()
464 gdFree(info); in gdImageCreateFromBmpCtx()
468 BMP_DEBUG(printf("Numcolours: %d\n", info->numcolors)); in gdImageCreateFromBmpCtx()
469 BMP_DEBUG(printf("Width: %d\n", info->width)); in gdImageCreateFromBmpCtx()
470 BMP_DEBUG(printf("Height: %d\n", info->height)); in gdImageCreateFromBmpCtx()
471 BMP_DEBUG(printf("Planes: %d\n", info->numplanes)); in gdImageCreateFromBmpCtx()
472 BMP_DEBUG(printf("Depth: %d\n", info->depth)); in gdImageCreateFromBmpCtx()
475 if (info->depth >= 16) { in gdImageCreateFromBmpCtx()
476 im = gdImageCreateTrueColor(info->width, info->height); in gdImageCreateFromBmpCtx()
478 im = gdImageCreate(info->width, info->height); in gdImageCreateFromBmpCtx()
483 gdFree(info); in gdImageCreateFromBmpCtx()
487 switch (info->depth) { in gdImageCreateFromBmpCtx()
490 error = bmp_read_1bit(im, infile, info, hdr); in gdImageCreateFromBmpCtx()
494 error = bmp_read_4bit(im, infile, info, hdr); in gdImageCreateFromBmpCtx()
498 error = bmp_read_8bit(im, infile, info, hdr); in gdImageCreateFromBmpCtx()
504 error = bmp_read_direct(im, infile, info, hdr); in gdImageCreateFromBmpCtx()
512 gdFree(info); in gdImageCreateFromBmpCtx()
536 static int bmp_read_info(gdIOCtx *infile, bmp_info_t *info) in bmp_read_info() argument
539 if (!gdGetIntLSB(&info->len, infile)) { in bmp_read_info()
543 switch (info->len) { in bmp_read_info()
549 if (bmp_read_windows_v3_info(infile, info)) { in bmp_read_info()
554 if (bmp_read_os2_v1_info(infile, info)) { in bmp_read_info()
559 if (bmp_read_os2_v2_info(infile, info)) { in bmp_read_info()
570 static int bmp_read_windows_v3_info(gdIOCtxPtr infile, bmp_info_t *info) in bmp_read_windows_v3_info() argument
573 !gdGetIntLSB(&info->width, infile) || in bmp_read_windows_v3_info()
574 !gdGetIntLSB(&info->height, infile) || in bmp_read_windows_v3_info()
575 !gdGetWordLSB(&info->numplanes, infile) || in bmp_read_windows_v3_info()
576 !gdGetWordLSB(&info->depth, infile) || in bmp_read_windows_v3_info()
577 !gdGetIntLSB(&info->enctype, infile) || in bmp_read_windows_v3_info()
578 !gdGetIntLSB(&info->size, infile) || in bmp_read_windows_v3_info()
579 !gdGetIntLSB(&info->hres, infile) || in bmp_read_windows_v3_info()
580 !gdGetIntLSB(&info->vres, infile) || in bmp_read_windows_v3_info()
581 !gdGetIntLSB(&info->numcolors, infile) || in bmp_read_windows_v3_info()
582 !gdGetIntLSB(&info->mincolors, infile) in bmp_read_windows_v3_info()
587 if (info->height < 0) { in bmp_read_windows_v3_info()
588 info->topdown = 1; in bmp_read_windows_v3_info()
589 info->height = -info->height; in bmp_read_windows_v3_info()
591 info->topdown = 0; in bmp_read_windows_v3_info()
594 info->type = BMP_PALETTE_4; in bmp_read_windows_v3_info()
596 if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 || in bmp_read_windows_v3_info()
597 info->depth <= 0 || info->numcolors < 0 || info->mincolors < 0) { in bmp_read_windows_v3_info()
604 static int bmp_read_os2_v1_info(gdIOCtxPtr infile, bmp_info_t *info) in bmp_read_os2_v1_info() argument
607 !gdGetWordLSB((signed short int *)&info->width, infile) || in bmp_read_os2_v1_info()
608 !gdGetWordLSB((signed short int *)&info->height, infile) || in bmp_read_os2_v1_info()
609 !gdGetWordLSB(&info->numplanes, infile) || in bmp_read_os2_v1_info()
610 !gdGetWordLSB(&info->depth, infile) in bmp_read_os2_v1_info()
616 info->topdown = 0; in bmp_read_os2_v1_info()
618 info->numcolors = 1 << info->depth; in bmp_read_os2_v1_info()
619 info->type = BMP_PALETTE_3; in bmp_read_os2_v1_info()
621 if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 || in bmp_read_os2_v1_info()
622 info->depth <= 0 || info->numcolors < 0) { in bmp_read_os2_v1_info()
629 static int bmp_read_os2_v2_info(gdIOCtxPtr infile, bmp_info_t *info) in bmp_read_os2_v2_info() argument
633 !gdGetIntLSB(&info->width, infile) || in bmp_read_os2_v2_info()
634 !gdGetIntLSB(&info->height, infile) || in bmp_read_os2_v2_info()
635 !gdGetWordLSB(&info->numplanes, infile) || in bmp_read_os2_v2_info()
636 !gdGetWordLSB(&info->depth, infile) || in bmp_read_os2_v2_info()
637 !gdGetIntLSB(&info->enctype, infile) || in bmp_read_os2_v2_info()
638 !gdGetIntLSB(&info->size, infile) || in bmp_read_os2_v2_info()
639 !gdGetIntLSB(&info->hres, infile) || in bmp_read_os2_v2_info()
640 !gdGetIntLSB(&info->vres, infile) || in bmp_read_os2_v2_info()
641 !gdGetIntLSB(&info->numcolors, infile) || in bmp_read_os2_v2_info()
642 !gdGetIntLSB(&info->mincolors, infile) in bmp_read_os2_v2_info()
652 if (info->height < 0) { in bmp_read_os2_v2_info()
653 info->topdown = 1; in bmp_read_os2_v2_info()
654 info->height = -info->height; in bmp_read_os2_v2_info()
656 info->topdown = 0; in bmp_read_os2_v2_info()
659 info->type = BMP_PALETTE_4; in bmp_read_os2_v2_info()
661 if (info->width <= 0 || info->height <= 0 || info->numplanes <= 0 || in bmp_read_os2_v2_info()
662 info->depth <= 0 || info->numcolors < 0 || info->mincolors < 0) { in bmp_read_os2_v2_info()
670 static int bmp_read_direct(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header) in bmp_read_direct() argument
676 switch(info->enctype) { in bmp_read_direct()
682 if (info->depth == 24) { in bmp_read_direct()
691 if (info->depth != 8) { in bmp_read_direct()
697 if (info->depth != 4) { in bmp_read_direct()
718 padding = ((int)(info->depth / 8) * info->width) % 4; in bmp_read_direct()
724 for (ypos = 0; ypos < info->height; ++ypos) { in bmp_read_direct()
725 if (info->topdown) { in bmp_read_direct()
728 row = info->height - ypos - 1; in bmp_read_direct()
731 for (xpos = 0; xpos < info->width; xpos++) { in bmp_read_direct()
732 if (info->depth == 16) { in bmp_read_direct()
741 } else if (info->depth == 24) { in bmp_read_direct()
785 static int bmp_read_1bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header) in bmp_read_1bit() argument
790 if (info->enctype != BMP_BI_RGB) { in bmp_read_1bit()
794 if (!info->numcolors) { in bmp_read_1bit()
795 info->numcolors = 2; in bmp_read_1bit()
796 } else if (info->numcolors < 0 || info->numcolors > 2) { in bmp_read_1bit()
800 if (bmp_read_palette(im, infile, info->numcolors, (info->type == BMP_PALETTE_4))) { in bmp_read_1bit()
804 im->colorsTotal = info->numcolors; in bmp_read_1bit()
815 padding = (info->width + 7) / 8 % 4; in bmp_read_1bit()
820 for (ypos = 0; ypos < info->height; ++ypos) { in bmp_read_1bit()
821 if (info->topdown) { in bmp_read_1bit()
824 row = info->height - ypos - 1; in bmp_read_1bit()
827 for (xpos = 0; xpos < info->width; xpos += 8) { in bmp_read_1bit()
840 if ((xpos + bit) >= info->width) { in bmp_read_1bit()
855 static int bmp_read_4bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header) in bmp_read_4bit() argument
860 if (info->enctype != BMP_BI_RGB && info->enctype != BMP_BI_RLE4) { in bmp_read_4bit()
864 if (!info->numcolors) { in bmp_read_4bit()
865 info->numcolors = 16; in bmp_read_4bit()
866 } else if (info->numcolors < 0 || info->numcolors > 16) { in bmp_read_4bit()
870 if (bmp_read_palette(im, infile, info->numcolors, (info->type == BMP_PALETTE_4))) { in bmp_read_4bit()
874 im->colorsTotal = info->numcolors; in bmp_read_4bit()
885 padding = ((int)ceil(0.5 * info->width)) % 4; in bmp_read_4bit()
890 switch (info->enctype) { in bmp_read_4bit()
892 for (ypos = 0; ypos < info->height; ++ypos) { in bmp_read_4bit()
893 if (info->topdown) { in bmp_read_4bit()
896 row = info->height - ypos - 1; in bmp_read_4bit()
899 for (xpos = 0; xpos < info->width; xpos += 2) { in bmp_read_4bit()
911 if (xpos >= info->width) { in bmp_read_4bit()
931 if (bmp_read_rle(im, infile, info)) { in bmp_read_4bit()
942 static int bmp_read_8bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp_hdr_t *header) in bmp_read_8bit() argument
947 if (info->enctype != BMP_BI_RGB && info->enctype != BMP_BI_RLE8) { in bmp_read_8bit()
951 if (!info->numcolors) { in bmp_read_8bit()
952 info->numcolors = 256; in bmp_read_8bit()
953 } else if (info->numcolors < 0 || info->numcolors > 256) { in bmp_read_8bit()
957 if (bmp_read_palette(im, infile, info->numcolors, (info->type == BMP_PALETTE_4))) { in bmp_read_8bit()
961 im->colorsTotal = info->numcolors; in bmp_read_8bit()
972 padding = (1 * info->width) % 4; in bmp_read_8bit()
977 switch (info->enctype) { in bmp_read_8bit()
979 for (ypos = 0; ypos < info->height; ++ypos) { in bmp_read_8bit()
980 if (info->topdown) { in bmp_read_8bit()
983 row = info->height - ypos - 1; in bmp_read_8bit()
986 for (xpos = 0; xpos < info->width; ++xpos) { in bmp_read_8bit()
1006 if (bmp_read_rle(im, infile, info)) { in bmp_read_8bit()
1017 static int bmp_read_rle(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info) in bmp_read_rle() argument
1023 int pixels_per_byte = 8 / info->depth; in bmp_read_rle()
1025 for (ypos = 0; ypos < info->height && xpos <= info->width;) { in bmp_read_rle()
1029 row = info->height - ypos - 1; in bmp_read_rle()
1036 for (i = 0; (i < rle_length) && (xpos < info->width);) { in bmp_read_rle()
1037 …for (j = 1; (j <= pixels_per_byte) && (xpos < info->width) && (i < rle_length); j++, xpos++, i++) { in bmp_read_rle()
1038 …index = (rle_data & (((1 << info->depth) - 1) << (8 - (j * info->depth)))) >> (8 - (j * info->dept… in bmp_read_rle()
1048 for (i = 0; (i < rle_data) && (xpos < info->width); i += pixels_per_byte) { in bmp_read_rle()
1060 for (j = 1; (j <= max_pixels) && (xpos < info->width); j++, xpos++) { in bmp_read_rle()
1061 int temp = (index >> (8 - (j * info->depth))) & ((1 << info->depth) - 1); in bmp_read_rle()