首页>代码>java编写的音乐播放器yoyoplayer程序代码,界面很炫>/YOYOPlayer/src/com/ctreber/aclib/image/ico/AbstractBitmap.java
package com.ctreber.aclib.image.ico;

import java.awt.image.BufferedImage;
import java.io.IOException;

import com.ctreber.aclib.codec.AbstractDecoder;

/**
 * <p>
 * Parent class for all icon bitmaps, indexed or RGB.
 * </p>
 * <p>
 * Why is creation and read() not one thing? Because we might want to create the
 * object, fill it step by step, and then write it.
 * </p>
 * @see com.ctreber.aclib.image.ico.AbstractBitmapIndexed
 * @see com.ctreber.aclib.image.ico.AbstractBitmapRGB
 * @author &copy; Christian Treber, ct@ctreber.com
 */
public abstract class AbstractBitmap {
    /** Describes the bitmap. */
    protected BitmapDescriptor _descriptor;

    /**
     * @param pDescriptor The image descriptor.
     */
    // @PMD:REVIEWED:CallSuperInConstructor: by Chris on 06.03.06 10:27
    public AbstractBitmap(final BitmapDescriptor pDescriptor) {
        _descriptor = pDescriptor;
    }

    /**
     * Create an RGB image rendition of this bitmap.
     * @return A BufferedImage rendition (RGB) of this bitmap.
     */
    public abstract BufferedImage createImageRGB();

    /**
     * Read bitmap from the decoder into class internal data structures.
     * Implemented by specific Bitmap classes.
     * @param pDec The decoder.
     * @throws IOException
     */
    abstract void read(AbstractDecoder pDec) throws IOException;

    /**
     * The (manipulated height - read on). I found that a) mostly (but not
     * always) the height reported by the header is double the real size, and b)
     * that the descriptor is usually correct.
     * @return Returns the height.
     */
    protected int getHeight() {
        if (_descriptor.getWidth() == _descriptor.getHeight() / 2) {
            // FIXME Now, this is pretty experimental.
            return _descriptor.getWidth();
        }

        return _descriptor.getHeight();
    }

    /**
     * Get the bitmap width.
     * @return Returns the width.
     */
    protected int getWidth() {
        return _descriptor.getWidth();
    }

    protected int getColorCount() {
        return _descriptor.getHeader().getColorCount();
    }

    /**
     * Get the bitmap descriptor.
     * @return Returns the descriptor.
     */
    public BitmapDescriptor getDescriptor() {
        return _descriptor;
    }

    /**
     * @param pDescriptor
     *            The descriptor to set.
     */
    void setDescriptor(final BitmapDescriptor pDescriptor) {
        _descriptor = pDescriptor;
    }

    /**
     * Simply returns the class name which reflects the bitmap type.
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return getClass().toString();
    }
}
最近下载更多
lzl111213  LV1 2023年6月21日
wyx065747  LV67 2022年5月7日
微信网友_5852742079762432  LV6 2022年4月11日
一个好人520  LV10 2021年9月29日
wangdongtai  LV31 2021年8月2日
yxcker  LV7 2021年7月9日
时光凉薄  LV2 2021年7月9日
Mayoubin2001  LV21 2021年6月10日
adim10912  LV2 2020年12月27日
Demo1111  LV30 2020年12月25日
最近浏览更多
cxz2132132  LV11 2023年12月9日
pangzhihui  LV12 2023年11月13日
543539666  LV7 2023年8月30日
NicLee 2023年7月7日
暂无贡献等级
lzl111213  LV1 2023年6月21日
cmq258159  LV2 2023年6月20日
数据库1  LV12 2023年5月17日
钱永越 2023年5月13日
暂无贡献等级
WanLiuYun  LV12 2023年4月14日
xingxing1234  LV10 2023年3月22日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友