parse embedded PNG image
| 3165 | |
| 3166 | //parse embedded PNG image |
| 3167 | static void parseImage(NSVGparser* p, const char** dict) |
| 3168 | { |
| 3169 | // NSVGattrib* attr = nsvg__getAttr(p); |
| 3170 | NSVGpattern *pt = NULL; |
| 3171 | int i; |
| 3172 | UINTN len = 0; |
| 3173 | float w,h; |
| 3174 | const char *href = NULL; |
| 3175 | UINT8 *tmpData = NULL; |
| 3176 | // EG_IMAGE *NewImage = NULL; |
| 3177 | XImage *NewImage = new XImage; |
| 3178 | |
| 3179 | for (i = 0; dict[i]; i += 2) { |
| 3180 | if (strcmp(dict[i], "width") == 0) { |
| 3181 | w = nsvg__parseCoordinate(p, dict[i+1], 0.0f, nsvg__actualWidth(p)); |
| 3182 | } else if (strcmp(dict[i], "height") == 0) { |
| 3183 | h = nsvg__parseCoordinate(p, dict[i+1], 0.0f, nsvg__actualHeight(p)); |
| 3184 | } else if (strcmp(dict[i], "xlink:href") == 0) { |
| 3185 | href = dict[i+1]; |
| 3186 | } else { |
| 3187 | nsvg__parseAttr(p, dict[i], dict[i + 1]); |
| 3188 | } |
| 3189 | } |
| 3190 | if (!href || (strstr(href, "data:image/png;") == NULL)) { |
| 3191 | return; |
| 3192 | } |
| 3193 | href = strstr(href, "base64,") + 7; |
| 3194 | if (p->patternFlag) { |
| 3195 | pt = p->patterns; //the last one |
| 3196 | } |
| 3197 | tmpData = (UINT8 *)Base64DecodeClover((char*)href, &len); |
| 3198 | if (len == 0) { |
| 3199 | DBG("image not decoded from base64\n"); |
| 3200 | } |
| 3201 | // NewImage = egDecodePNG(tmpData, len, TRUE); |
| 3202 | NewImage->FromPNG(tmpData, len); |
| 3203 | pt->image = (void *)NewImage; |
| 3204 | if (tmpData) { |
| 3205 | FreePool(tmpData); |
| 3206 | } |
| 3207 | } |
| 3208 | |
| 3209 | static void parsePattern(NSVGparser* p, const char** dict) |
| 3210 | { |
no test coverage detected