LIBAROMA_CANVASP libaroma_svg_ex( LIBAROMA_STREAMP stream, byte freeStream, byte use_px) { LIBAROMA_CANVASP cv = NULL; if (!stream) { return NULL; } char * data = libaroma_stream_to_string(stream,0); if (data){ NSVGimage *image = NULL; if (!use_px){ image=nsvgParse(data, "dp", ((float) libaroma_fb()->dpi)); } else{ image=nsvgParse(data, "px", ((float) libaroma_fb()->dpi)); } free(data); if (image == NULL) { ALOGW("libaroma_svg: Could not open SVG image."); goto exit; } NSVGrasterizer *rast =nsvgCreateRasterizer(); if (rast == NULL) { printf("libaroma_svg: Could not init rasterizer."); nsvgDelete(image); goto exit; } if (!use_px){ cv = libaroma_canvas_ex(libaroma_dp(image->width),libaroma_dp(image->height),1); } else{ cv = libaroma_canvas_ex(image->width,image->height,1); } libaroma_canvas_setcolor(cv,0,0); nsvgRasterize(rast,image,0,0,1,cv); nsvgDelete(image); nsvgDeleteRasterizer(rast); } exit: if (freeStream) { libaroma_stream_close(stream); } return cv; }
/* * Function : libaroma_getprop * Return Value: char * * Descriptions: get prop from stream */ char * libaroma_getprop( char * key, LIBAROMA_STREAMP stream, byte freeStream){ char * buffer=libaroma_stream_to_string(stream,freeStream); if (buffer==NULL) { return NULL; } char * result = NULL; char * line = strtok(buffer, "\n"); do { while (*line && isspace(*line)) { ++line; } if (*line == '\0' || *line == '#') { continue; } char * equal = strchr(line, '='); if (equal==NULL) { goto done; } char * key_end = equal - 1; while (key_end > line && isspace(*key_end)){ --key_end; } key_end[1] = '\0'; if (strcmp(key, line) != 0) { continue; } char * val_start = equal+1; while (*val_start && isspace(*val_start)) { ++val_start; } char * val_end = val_start + strlen(val_start) - 1; while (val_end > val_start && isspace(*val_end)) { --val_end; } val_end[1] = '\0'; result = strdup(val_start); break; } while ((line = strtok(NULL, "\n"))); done: free(buffer); return result; } /* End of libaroma_getprop */