当前位置: 首页>>代码示例>>Java>>正文


Java DDSCompressor类代码示例

本文整理汇总了Java中gov.nasa.worldwind.formats.dds.DDSCompressor的典型用法代码示例。如果您正苦于以下问题:Java DDSCompressor类的具体用法?Java DDSCompressor怎么用?Java DDSCompressor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DDSCompressor类属于gov.nasa.worldwind.formats.dds包,在下文中一共展示了DDSCompressor类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readTexture

import gov.nasa.worldwind.formats.dds.DDSCompressor; //导入依赖的package包/类
/**
 * Reads and returns the texture data at the specified URL, optionally converting it to the specified format and
 * generating mip-maps. If <code>textureFormat</code> is a recognized mime type, this returns the texture data in
 * the specified format. Otherwise, this returns the texture data in its native format. If <code>useMipMaps</code>
 * is true, this generates mip maps for any non-DDS texture data, and uses any mip-maps contained in DDS texture
 * data.
 * <p/>
 * Supported texture formats are as follows: <ul> <li><code>image/dds</code> - Returns DDS texture data, converting
 * the data to DDS if necessary. If the data is already in DDS format it's returned as-is.</li> </ul>
 *
 * @param url           the URL referencing the texture data to read.
 * @param textureFormat the texture data format to return.
 * @param useMipMaps    true to generate mip-maps for the texture data or use mip maps already in the texture data,
 *                      and false to read the texture data without generating or using mip-maps.
 *
 * @return TextureData the texture data from the specified URL, in the specified format and with mip-maps.
 */
	
protected TextureData readTexture(java.net.URL url, String textureFormat, boolean useMipMaps)
{
    try
    {
        // If the caller has enabled texture compression, and the texture data is not a DDS file, then use read the
        // texture data and convert it to DDS.
        if ("image/dds".equalsIgnoreCase(textureFormat) && !url.toString().toLowerCase().endsWith("dds"))
        {
            // Configure a DDS compressor to generate mipmaps based according to the 'useMipMaps' parameter, and
            // convert the image URL to a compressed DDS format.
            DXTCompressionAttributes attributes = DDSCompressor.getDefaultCompressionAttributes();
            attributes.setBuildMipmaps(useMipMaps);
            ByteBuffer buffer = DDSCompressor.compressImageURL(url, attributes);

            return OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(),
                    WWIO.getInputStreamFromByteBuffer(buffer), useMipMaps);
        }
        // If the caller has disabled texture compression, or if the texture data is already a DDS file, then read
        // the texture data without converting it.
        else
        {
        	return OGLUtil.newTextureData(Configuration.getMaxCompatibleGLProfile(), url, useMipMaps);
        }
    }
    catch (Exception e)
    {
        String msg = Logging.getMessage("layers.TextureLayer.ExceptionAttemptingToReadTextureFile", url);
        Logging.logger().log(java.util.logging.Level.SEVERE, msg, e);
        return null;
    }
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:50,代码来源:BasicScalingTiledImageLayer.java

示例2: installWWDotNetFile

import gov.nasa.worldwind.formats.dds.DDSCompressor; //导入依赖的package包/类
private void installWWDotNetFile(java.io.File source, java.io.File destination, ProductionState productionState)
    throws java.io.IOException
{
    // Bypass file installation if:
    // (a) destination is newer than source, and
    // (b) source and destination have identical size.
    if (destination.exists() && source.lastModified() >= destination.lastModified()
        && source.length() == destination.length())
    {
        return;
    }

    String sourceSuffix = WWIO.getSuffix(source.getName());
    String destinationSuffix = WWIO.getSuffix(destination.getName());

    // Source and destination types match. Copy the source file directly.
    if (sourceSuffix.equalsIgnoreCase(destinationSuffix))
    {
        WWIO.copyFile(source, destination);
    }
    // Destination type is different. Convert the source file and write the converstion to the destionation.
    else
    {
        if (destinationSuffix.equalsIgnoreCase("dds"))
        {
            java.nio.ByteBuffer sourceBuffer = DDSCompressor.compressImageFile(source);
            WWIO.saveBuffer(sourceBuffer, destination);
        }
        else
        {
            java.awt.image.BufferedImage sourceImage = javax.imageio.ImageIO.read(source);
            javax.imageio.ImageIO.write(sourceImage, destinationSuffix, destination);
        }
    }

    this.updateProgress(productionState);
}
 
开发者ID:TrilogisIT,项目名称:FAO_Application,代码行数:38,代码来源:WWDotNetLayerSetConverter.java


注:本文中的gov.nasa.worldwind.formats.dds.DDSCompressor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。