當前位置: 首頁>>代碼示例>>Java>>正文


Java DataBufferByte.getData方法代碼示例

本文整理匯總了Java中java.awt.image.DataBufferByte.getData方法的典型用法代碼示例。如果您正苦於以下問題:Java DataBufferByte.getData方法的具體用法?Java DataBufferByte.getData怎麽用?Java DataBufferByte.getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.image.DataBufferByte的用法示例。


在下文中一共展示了DataBufferByte.getData方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: matToBufferedImage

import java.awt.image.DataBufferByte; //導入方法依賴的package包/類
public BufferedImage matToBufferedImage(Mat mat) {

        if (mat.height() > 0 && mat.width() > 0) {
            BufferedImage image = new BufferedImage(mat.width(), mat.height(), BufferedImage.TYPE_3BYTE_BGR);
            WritableRaster raster = image.getRaster();
            DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer();
            byte[] data = dataBuffer.getData();
            mat.get(0, 0, data);
            return image;
        }
        return null;
    }
 
開發者ID:Plasmoxy,項目名稱:AquamarineLake,代碼行數:13,代碼來源:DrawPanel.java

示例2: bufferedImage

import java.awt.image.DataBufferByte; //導入方法依賴的package包/類
public BufferedImage bufferedImage(Mat mat) {

        if (mat.height() > 0 && mat.width() > 0) {
            BufferedImage image = new BufferedImage(mat.width(), mat.height(), BufferedImage.TYPE_3BYTE_BGR);
            WritableRaster raster = image.getRaster();
            DataBufferByte dataBuffer = (DataBufferByte) raster.getDataBuffer();
            byte[] data = dataBuffer.getData();
            mat.get(0, 0, data);
            return image;
        }
        return null;
    }
 
開發者ID:Plasmoxy,項目名稱:AquamarineLake,代碼行數:13,代碼來源:DrawPanel.java

示例3: getByteData

import java.awt.image.DataBufferByte; //導入方法依賴的package包/類
/**
 * Obtains the data from the raster of the given image as a byte array.
 *
 * @param image The image
 * @return The image data
 * @throws IllegalArgumentException If the given image is not backed by a
 * DataBufferByte. Usually, only BufferedImages of with the types
 * BufferedImage.TYPE_BYTE_* have a DataBufferByte
 */
public static byte[] getByteData(BufferedImage image) {
    DataBuffer dataBuffer = image.getRaster().getDataBuffer();
    if (!(dataBuffer instanceof DataBufferByte)) {
        throw new IllegalArgumentException(
                "Image does not contain a DataBufferByte");
    }
    DataBufferByte dataBufferByte = (DataBufferByte) dataBuffer;
    byte data[] = dataBufferByte.getData();
    return data;
}
 
開發者ID:buni-rock,項目名稱:Pixie,代碼行數:20,代碼來源:Utils.java

示例4: readFrames

import java.awt.image.DataBufferByte; //導入方法依賴的package包/類
protected void readFrames(InputStream inputStream) {
	try {
		long t0=System.currentTimeMillis()-1; // -1: Avoid div by zero in very fast cases
		while(true)
		{
			BufferedImage im=frames[writePtr];
			DataBufferByte b=(DataBufferByte)im.getRaster().getDataBuffer();
			byte[] data=b.getData();
			int at=0;
			while(at<data.length)
			{
				int n=inputStream.read(data, at, data.length-at);
				if(n<0)
				{
					throw new EOFException();
				}
				at+=n;
			}
			nRead++;
			writePtr++;
			writePtr%=frames.length;
			long t=System.currentTimeMillis();
			fps=((double)nRead)/(t-t0)*1000;
		}
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
開發者ID:rizsi,項目名稱:rcom,代碼行數:30,代碼來源:VideoStreamProcessor.java

示例5: getByteData

import java.awt.image.DataBufferByte; //導入方法依賴的package包/類
/**
 * @param userSpaceImage
 * @return byte array of supplied image
 */
public byte[] getByteData(BufferedImage userSpaceImage) {
    WritableRaster raster = userSpaceImage.getRaster();
    DataBufferByte buffer = (DataBufferByte) raster.getDataBuffer();
    return buffer.getData();
}
 
開發者ID:varunon9,項目名稱:Image-Stegano,代碼行數:10,代碼來源:ImageUtility.java

示例6: imageToPlatformBytes

import java.awt.image.DataBufferByte; //導入方法依賴的package包/類
@Override
protected byte[] imageToPlatformBytes(Image image, long format)
        throws IOException {
    String mimeType = null;
    if (format == CF_PNG) {
        mimeType = "image/png";
    } else if (format == CF_JFIF) {
        mimeType = "image/jpeg";
    }
    if (mimeType != null) {
        return imageToStandardBytes(image, mimeType);
    }

    int width = 0;
    int height = 0;

    if (image instanceof ToolkitImage) {
        ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
        ir.reconstruct(ImageObserver.ALLBITS);
        width = ir.getWidth();
        height = ir.getHeight();
    } else {
        width = image.getWidth(null);
        height = image.getHeight(null);
    }

    // Fix for 4919639.
    // Some Windows native applications (e.g. clipbrd.exe) do not handle
    // 32-bpp DIBs correctly.
    // As a workaround we switched to 24-bpp DIBs.
    // MSDN prescribes that the bitmap array for a 24-bpp should consist of
    // 3-byte triplets representing blue, green and red components of a
    // pixel respectively. Additionally each scan line must be padded with
    // zeroes to end on a LONG data-type boundary. LONG is always 32-bit.
    // We render the given Image to a BufferedImage of type TYPE_3BYTE_BGR
    // with non-default scanline stride and pass the resulting data buffer
    // to the native code to fill the BITMAPINFO structure.
    int mod = (width * 3) % 4;
    int pad = mod > 0 ? 4 - mod : 0;

    ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    int[] nBits = {8, 8, 8};
    int[] bOffs = {2, 1, 0};
    ColorModel colorModel =
            new ComponentColorModel(cs, nBits, false, false,
                    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
    WritableRaster raster =
            Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height,
                    width * 3 + pad, 3, bOffs, null);

    BufferedImage bimage = new BufferedImage(colorModel, raster, false, null);

    // Some Windows native applications (e.g. clipbrd.exe) do not understand
    // top-down DIBs.
    // So we flip the image vertically and create a bottom-up DIB.
    AffineTransform imageFlipTransform =
            new AffineTransform(1, 0, 0, -1, 0, height);

    Graphics2D g2d = bimage.createGraphics();

    try {
        g2d.drawImage(image, imageFlipTransform, null);
    } finally {
        g2d.dispose();
    }

    DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer();

    byte[] imageData = buffer.getData();
    return imageDataToPlatformImageBytes(imageData, width, height, format);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:72,代碼來源:WDataTransferer.java

示例7: get_byte_data

import java.awt.image.DataBufferByte; //導入方法依賴的package包/類
private byte[] get_byte_data(BufferedImage image)
{
        WritableRaster raster   = image.getRaster();
        DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer();
        return buffer.getData();
}
 
開發者ID:lemon65,項目名稱:Crypto,代碼行數:7,代碼來源:Steganography.java


注:本文中的java.awt.image.DataBufferByte.getData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。