FileDocCategorySizeDatePackage
StandardArtwork.javaAPI DocJaudiotagger 2.0.45565Wed Jun 08 11:06:58 BST 2011org.jaudiotagger.tag.images

StandardArtwork

public class StandardArtwork extends Object implements Artwork
Represents artwork in a format independent way

Fields Summary
private byte[]
binaryData
private String
mimeType
private String
description
private boolean
isLinked
private String
imageUrl
private int
pictureType
private int
width
private int
height
Constructors Summary
public StandardArtwork()


     
    

    
Methods Summary
public static org.jaudiotagger.tag.images.StandardArtworkcreateArtworkFromFile(java.io.File file)
Create Artwork from File

param
file
return
throws
java.io.IOException

        StandardArtwork artwork = new StandardArtwork();
        artwork.setFromFile(file);
        return artwork;
    
public static org.jaudiotagger.tag.images.StandardArtworkcreateArtworkFromMetadataBlockDataPicture(org.jaudiotagger.audio.flac.metadatablock.MetadataBlockDataPicture coverArt)
Create artwork from Flac block

param
coverArt
return

        StandardArtwork artwork = new StandardArtwork();
        artwork.setFromMetadataBlockDataPicture(coverArt);
        return artwork;
    
public static org.jaudiotagger.tag.images.StandardArtworkcreateLinkedArtworkFromURL(java.lang.String url)

        StandardArtwork artwork = new StandardArtwork();
        artwork.setLinkedFromURL(url);
        return artwork;
    
public byte[]getBinaryData()

        return binaryData;
    
public java.lang.StringgetDescription()

        return description;
    
public intgetHeight()

        return height;
    
public java.lang.ObjectgetImage()

        ImageInputStream iis = ImageIO.createImageInputStream(new ByteArrayInputStream(getBinaryData()));
        BufferedImage bi = ImageIO.read(iis);
        return bi;
    
public java.lang.StringgetImageUrl()

        return imageUrl;
    
public java.lang.StringgetMimeType()

        return mimeType;
    
public intgetPictureType()

        return pictureType;
    
public intgetWidth()

        return width;
    
public booleanisLinked()

        return isLinked;
    
public voidsetBinaryData(byte[] binaryData)

        this.binaryData = binaryData;
    
public voidsetDescription(java.lang.String description)

        this.description = description;
    
public voidsetFromFile(java.io.File file)
Create Artwork from File

param
file
throws
java.io.IOException

        RandomAccessFile imageFile = new RandomAccessFile(file, "r");
        byte[] imagedata = new byte[(int) imageFile.length()];
        imageFile.read(imagedata);
        imageFile.close();

        setBinaryData(imagedata);
        setMimeType(ImageFormats.getMimeTypeForBinarySignature(imagedata));
        setDescription("");
        setPictureType(PictureTypes.DEFAULT_ID);
    
public voidsetFromMetadataBlockDataPicture(org.jaudiotagger.audio.flac.metadatablock.MetadataBlockDataPicture coverArt)
Populate Artwork from MetadataBlockDataPicture as used by Flac and VorbisComment

param
coverArt

        setMimeType(coverArt.getMimeType());
        setDescription(coverArt.getDescription());
        setPictureType(coverArt.getPictureType());       
        if(coverArt.isImageUrl())
        {
            setLinked(coverArt.isImageUrl());
            setImageUrl(coverArt.getImageUrl());
        }
        else
        {
            setBinaryData(coverArt.getImageData());
        }
        setWidth(coverArt.getWidth());
        setHeight(coverArt.getHeight());
    
public voidsetHeight(int height)

        this.height = height;
    
public booleansetImageFromData()
Should be called when you wish to prime the artwork for saving

return

        try
        {
            BufferedImage image = (BufferedImage)getImage();
            setWidth(image.getWidth());
            setHeight(image.getHeight());
        }
        catch(IOException ioe)
        {
            return false;
        }
        return true;
    
public voidsetImageUrl(java.lang.String imageUrl)

        this.imageUrl = imageUrl;
    
public voidsetLinked(boolean linked)

        isLinked = linked;
    
public voidsetLinkedFromURL(java.lang.String url)
Create Linked Artwork from URL

param
url
throws
java.io.IOException

        setLinked(true);
        setImageUrl(url);
    
public voidsetMimeType(java.lang.String mimeType)

        this.mimeType = mimeType;
    
public voidsetPictureType(int pictureType)

        this.pictureType = pictureType;
    
public voidsetWidth(int width)

        this.width = width;