Constructors Summary |
---|
public MetadataBlockDataPicture(ByteBuffer rawdata)Initialize MetaBlockDataPicture from byteBuffer
initFromByteBuffer(rawdata);
|
public MetadataBlockDataPicture(MetadataBlockHeader header, RandomAccessFile raf)Construct picture block by reading from file, the header informs us how many bytes we should be reading from
ByteBuffer rawdata = ByteBuffer.allocate(header.getDataLength());
int bytesRead = raf.getChannel().read(rawdata);
if (bytesRead < header.getDataLength())
{
throw new IOException("Unable to read required number of databytes read:" + bytesRead + ":required:" + header.getDataLength());
}
rawdata.rewind();
initFromByteBuffer(rawdata);
|
public MetadataBlockDataPicture(byte[] imageData, int pictureType, String mimeType, String description, int width, int height, int colourDepth, int indexedColouredCount)Construct new MetadataPicture block
//Picture Type
this.pictureType = pictureType;
//MimeType
this.mimeType = mimeType;
//Description
this.description = description;
this.width = width;
this.height = height;
this.colourDepth = colourDepth;
this.indexedColouredCount = indexedColouredCount;
//ImageData
this.imageData = imageData;
|
Methods Summary |
---|
public void | copyContent(org.jaudiotagger.tag.TagField field)This method copies the data of the given field to the current data.
throw new UnsupportedOperationException();
|
public byte[] | getBytes()
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(Utils.getSizeBEInt32(pictureType));
baos.write(Utils.getSizeBEInt32(mimeType.length()));
baos.write(mimeType.getBytes("ISO-8859-1"));
baos.write(Utils.getSizeBEInt32(description.length()));
baos.write(description.getBytes("UTF-8"));
baos.write(Utils.getSizeBEInt32(width));
baos.write(Utils.getSizeBEInt32(height));
baos.write(Utils.getSizeBEInt32(colourDepth));
baos.write(Utils.getSizeBEInt32(indexedColouredCount));
baos.write(Utils.getSizeBEInt32(imageData.length));
baos.write(imageData);
return baos.toByteArray();
}
catch (IOException ioe)
{
throw new RuntimeException(ioe.getMessage());
}
|
public int | getColourDepth()
return colourDepth;
|
public java.lang.String | getDescription()
return description;
|
public int | getHeight()
return height;
|
public java.lang.String | getId()Returns the Id of the represented tag field.
This value should uniquely identify a kind of tag data, like title.
{@link org.jaudiotagger.audio.generic.AbstractTag} will use the "id" to summarize multiple
fields.
return FieldKey.COVER_ART.name();
|
public byte[] | getImageData()
return imageData;
|
public java.lang.String | getImageUrl()
if (isImageUrl())
{
return Utils.getString(getImageData(), 0, getImageData().length, TextEncoding.CHARSET_ISO_8859_1);
}
else
{
return "";
}
|
public int | getIndexedColourCount()
return indexedColouredCount;
|
public int | getLength()
return getBytes().length;
|
public java.lang.String | getMimeType()
return mimeType;
|
public int | getPictureType()
return pictureType;
|
public byte[] | getRawContent()This method delivers the binary representation of the fields data in
order to be directly written to the file.
return getBytes();
|
private java.lang.String | getString(java.nio.ByteBuffer rawdata, int length, java.lang.String charset)
byte[] tempbuffer = new byte[length];
rawdata.get(tempbuffer);
return new String(tempbuffer, charset);
|
public int | getWidth()
return width;
|
private void | initFromByteBuffer(java.nio.ByteBuffer rawdata)
//Picture Type
pictureType = rawdata.getInt();
if (pictureType >= PictureTypes.getInstanceOf().getSize())
{
throw new InvalidFrameException("PictureType was:" + pictureType + "but the maximum allowed is " + (PictureTypes.getInstanceOf().getSize() - 1));
}
//MimeType
int mimeTypeSize = rawdata.getInt();
mimeType = getString(rawdata, mimeTypeSize, "ISO-8859-1");
//Description
int descriptionSize = rawdata.getInt();
description = getString(rawdata, descriptionSize, "UTF-8");
//Image width
width = rawdata.getInt();
//Image height
height = rawdata.getInt();
//Colour Depth
colourDepth = rawdata.getInt();
//Indexed Colour Count
indexedColouredCount = rawdata.getInt();
//ImageData
int rawdataSize = rawdata.getInt();
imageData = new byte[rawdataSize];
rawdata.get(imageData);
logger.config("Read image:" + this.toString());
|
public boolean | isBinary()Determines whether the represented field contains (is made up of) binary
data, instead of text data.
Software can identify fields to be displayed because they are human
readable if this method returns false .
return true;
|
public void | isBinary(boolean b)This method will set the field to represent binary data.
Some implementations may support conversions.
As of now (Octobre 2005) there is no implementation really using this
method to perform useful operations.
//Do nothing, always true
|
public boolean | isCommon()Identifies a field to be of common use.
Some software may differ between common and not common fields. A common
one is for sure the title field. A web link may not be of common use for
tagging. However some file formats, or future development of users
expectations will make more fields common than now can be known.
return true;
|
public boolean | isEmpty()Determines whether the content of the field is empty.
return false;
|
public boolean | isImageUrl()
return getMimeType().equals(IMAGE_IS_URL);
|
public java.lang.String | toString()
return PictureTypes.getInstanceOf().getValueForId(pictureType) + ":" + mimeType + ":" + description + ":" + "width:" + width + ":height:" + height + ":colourdepth:" + colourDepth + ":indexedColourCount:" + indexedColouredCount + ":image size in bytes:" + imageData.length;
|