void tag_set_album_cover_from_bytes(char* album_cover_bytes, char* mimetype, int picture_size, ID3v2_tag* tag) { ID3v2_frame* album_cover_frame = NULL; if( ! (album_cover_frame = tag_get_album_cover(tag))) { album_cover_frame = new_frame(); add_to_list(tag->frames, album_cover_frame); } set_album_cover_frame(album_cover_bytes, mimetype, picture_size, album_cover_frame); }
// internal functions SDL_Surface *load_embedded (const char *file) { if (file == NULL) return NULL; if (access (file, F_OK) == -1) { fprintf (stderr,"%s: file '%s' does not exist\n", prog, file); return NULL; } if (access (file, R_OK) == -1) { fprintf (stderr,"%s: file '%s' cannot be read\n", prog, file); return NULL; } ID3v2_tag *tag = load_tag (file); if (tag == NULL) { return NULL; } ID3v2_frame *frame = tag_get_album_cover (tag); if (frame == NULL) { free_tag (tag); return NULL; } ID3v2_frame_apic_content *album_content = parse_apic_frame_content (frame); if (album_content == NULL) { free_tag (tag); return NULL; } SDL_Surface *sur = load_img_sdl (album_content->data, album_content->picture_size); free_tag (tag); free_apic_content (album_content); return sur; }