热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

java.awt.image.ColorModel.getNumColorComponents()方法的使用及代码示例

本文整理了Java中java.awt.image.ColorModel.getNumColorComponents()方法的一些代码示例,展示了ColorM

本文整理了Java中java.awt.image.ColorModel.getNumColorComponents()方法的一些代码示例,展示了ColorModel.getNumColorComponents()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ColorModel.getNumColorComponents()方法的具体详情如下:
包路径:java.awt.image.ColorModel
类名称:ColorModel
方法名:getNumColorComponents

ColorModel.getNumColorComponents介绍

[英]Returns the number of color components in this ColorModel. This is the number of components returned by ColorSpace#getNumComponents.
[中]返回此ColorModel中的颜色组件数。这是ColorSpace#getNumComponents返回的组件数。

代码示例

代码示例来源:origin: geoserver/geoserver

private boolean hasAlphaBand(ColorModel cm) {
// num components returns the alpha, num _color_ components does not
return (cm.getNumComponents() == 2 && cm.getNumColorComponents() == 1) /* gray-alpha case */
|| (cm.getNumComponents() == 4 && cm.getNumColorComponents() == 3) /* rgba case */;
}

代码示例来源:origin: geoserver/geoserver

private int getAlphaBandIndex(GridCoverage2D coverage) {
final ColorModel cm = coverage.getRenderedImage().getColorModel();
if (!cm.hasAlpha() || cm.getNumComponents() == cm.getNumColorComponents()) {
throw new IllegalArgumentException(
"The source coverage does not have an alpha band, cannot extract an "
+ "alpha band");
}
// the alpha band is always the last (see ComponentColorModel.getAlphaRaster or the
// getAlpha(object) code
if (cm.getNumColorComponents() == 1) {
// gray-alpha
return 1;
} else {
// rgba/argb
return 3;
}
}

代码示例来源:origin: geotools/geotools

final int defNumCompOnents= defaultCM.getNumColorComponents();
int actualNumCompOnents= actualCM.getNumColorComponents();
int colorCompOnentsDifference= Math.abs(defNumComponents - actualNumComponents);

代码示例来源:origin: apache/pdfbox

this.bytesPerPixel = image.getColorModel().getNumColorComponents() * bytesPerComponent;
this.imageType = image.getType();
this.hasAlpha = image.getColorModel().getNumComponents() != image.getColorModel()
.getNumColorComponents();
this.alphaImageData = hasAlpha ? new byte[width * height * bytesPerComponent] : null;

代码示例来源:origin: dermotte/LIRE

public void extract(BufferedImage img) {
int image_t care
assertEquals(ColorSpace.getInstance(ColorSpace.CS_sRGB), colorModel.getColorSpace());
for (int i = 0; i assertEquals(8, colorModel.getComponentSize(i));
}
}

代码示例来源:origin: geotools/geotools

if (!cm.hasAlpha() && cm.getNumColorComponents() != 2) {

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testGetColorModelGIF() {
URL resource = getClass().getResource("/tux.gif");
assertNotNull(resource);
Image source = Toolkit.getDefaultToolkit().createImage(resource);
assertNotNull(source);
BufferedImageFactory factory = new BufferedImageFactory(source);
ColorModel colorModel = factory.getColorModel();
assertNotNull(colorModel);
assertEquals(3, colorModel.getNumColorComponents());
assertEquals(ColorSpace.getInstance(ColorSpace.CS_sRGB), colorModel.getColorSpace());
assertTrue(colorModel instanceof IndexColorModel);
assertTrue(colorModel.hasAlpha());
assertEquals(4, colorModel.getNumComponents());
assertTrue(((IndexColorModel) colorModel).getTransparentPixel() >= 0);
assertEquals(Transparency.BITMASK, colorModel.getTransparency());
for (int i = 0; i assertEquals(8, colorModel.getComponentSize(i));
}
}

代码示例来源:origin: geotools/geotools

+ " is not supported, cannot perform color blending on it");
} else if (cm instanceof ComponentColorModel && cm.getNumColorComponents() == 3) {
accessor = new ByteRgbAccessor(raster, cm.hasAlpha());
} else {

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testGray() {
ImageTypeSpecifier spec = UInt32ImageTypeSpecifier.createInterleaved(GRAY, new int [] {0}, false, false);
assertEquals(1, spec.getNumBands());
assertEquals(1, spec.getNumComponents());
assertEquals(32, spec.getBitsPerBand(0));
assertThat(spec.getColorModel(), is(ComponentColorModel.class));
assertFalse(spec.getColorModel().hasAlpha());
assertFalse(spec.getColorModel().isAlphaPremultiplied());
assertEquals(1, spec.getColorModel().getNumComponents());
assertEquals(1, spec.getColorModel().getNumColorComponents());
assertThat(spec.getSampleModel(), is(PixelInterleavedSampleModel.class));
assertEquals(1, spec.getSampleModel().getNumBands());
assertEquals(1, spec.getSampleModel().getNumDataElements());
}

代码示例来源:origin: geotools/geotools

final int numColorBands = cm.getNumColorComponents();
final boolean hasAlpha = cm.hasAlpha();

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testGrayAlpha() {
ImageTypeSpecifier spec = UInt32ImageTypeSpecifier.createInterleaved(GRAY, new int [] {0, 1}, true, false);
assertEquals(2, spec.getNumBands());
assertEquals(2, spec.getNumComponents());
assertEquals(32, spec.getBitsPerBand(0));
assertEquals(32, spec.getBitsPerBand(1));
assertThat(spec.getColorModel(), is(ComponentColorModel.class));
assertTrue(spec.getColorModel().hasAlpha());
assertFalse(spec.getColorModel().isAlphaPremultiplied());
assertEquals(2, spec.getColorModel().getNumComponents());
assertEquals(1, spec.getColorModel().getNumColorComponents());
assertThat(spec.getSampleModel(), is(PixelInterleavedSampleModel.class));
assertEquals(2, spec.getSampleModel().getNumBands());
assertEquals(2, spec.getSampleModel().getNumDataElements());
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRGB() {
ImageTypeSpecifier spec = UInt32ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2}, false, false);
assertEquals(3, spec.getNumBands());
assertEquals(3, spec.getNumComponents());
assertEquals(32, spec.getBitsPerBand(0));
assertEquals(32, spec.getBitsPerBand(1));
assertEquals(32, spec.getBitsPerBand(2));
assertThat(spec.getColorModel(), is(ComponentColorModel.class));
assertFalse(spec.getColorModel().hasAlpha());
assertFalse(spec.getColorModel().isAlphaPremultiplied());
assertEquals(3, spec.getColorModel().getNumComponents());
assertEquals(3, spec.getColorModel().getNumColorComponents());
assertThat(spec.getSampleModel(), is(PixelInterleavedSampleModel.class));
assertEquals(3, spec.getSampleModel().getNumBands());
assertEquals(3, spec.getSampleModel().getNumDataElements());
}

代码示例来源:origin: geotools/geotools

.getRenderedImage();
imageWorker.retainBands(mosaic.getColorModel().getNumColorComponents());
imageWorker.addBand(maskedAlpha, false, true, null);
} else {

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRGBAlpha() {
ImageTypeSpecifier spec = UInt32ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2, 3}, true, false);
assertEquals(4, spec.getNumBands());
assertEquals(4, spec.getNumComponents());
assertEquals(32, spec.getBitsPerBand(0));
assertEquals(32, spec.getBitsPerBand(1));
assertEquals(32, spec.getBitsPerBand(2));
assertEquals(32, spec.getBitsPerBand(3));
assertThat(spec.getColorModel(), is(ComponentColorModel.class));
assertTrue(spec.getColorModel().hasAlpha());
assertFalse(spec.getColorModel().isAlphaPremultiplied());
assertEquals(4, spec.getColorModel().getNumComponents());
assertEquals(3, spec.getColorModel().getNumColorComponents());
assertThat(spec.getSampleModel(), is(PixelInterleavedSampleModel.class));
assertEquals(4, spec.getSampleModel().getNumBands());
assertEquals(4, spec.getSampleModel().getNumDataElements());
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testCMYK() {
ImageTypeSpecifier spec = UInt32ImageTypeSpecifier.createInterleaved(CMYK, new int [] {0, 1, 2, 3}, false, false);
assertEquals(4, spec.getNumBands());
assertEquals(4, spec.getNumComponents());
assertEquals(32, spec.getBitsPerBand(0));
assertEquals(32, spec.getBitsPerBand(1));
assertEquals(32, spec.getBitsPerBand(2));
assertEquals(32, spec.getBitsPerBand(3));
assertThat(spec.getColorModel(), is(ComponentColorModel.class));
assertFalse(spec.getColorModel().hasAlpha());
assertFalse(spec.getColorModel().isAlphaPremultiplied());
assertEquals(4, spec.getColorModel().getNumComponents());
assertEquals(4, spec.getColorModel().getNumColorComponents());
assertThat(spec.getSampleModel(), is(PixelInterleavedSampleModel.class));
assertEquals(4, spec.getSampleModel().getNumBands());
assertEquals(4, spec.getSampleModel().getNumDataElements());
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testRGBAlphaPre() {
ImageTypeSpecifier spec = UInt32ImageTypeSpecifier.createInterleaved(sRGB, new int [] {0, 1, 2, 3}, true, true);
assertEquals(4, spec.getNumBands());
assertEquals(4, spec.getNumComponents());
assertEquals(32, spec.getBitsPerBand(0));
assertEquals(32, spec.getBitsPerBand(1));
assertEquals(32, spec.getBitsPerBand(2));
assertEquals(32, spec.getBitsPerBand(3));
assertThat(spec.getColorModel(), is(ComponentColorModel.class));
assertTrue(spec.getColorModel().hasAlpha());
assertTrue(spec.getColorModel().isAlphaPremultiplied());
assertEquals(4, spec.getColorModel().getNumComponents());
assertEquals(3, spec.getColorModel().getNumColorComponents());
assertThat(spec.getSampleModel(), is(PixelInterleavedSampleModel.class));
assertEquals(4, spec.getSampleModel().getNumBands());
assertEquals(4, spec.getSampleModel().getNumDataElements());
}

代码示例来源:origin: haraldk/TwelveMonkeys

@Test
public void testCMYKAlpha() {
ImageTypeSpecifier spec = UInt32ImageTypeSpecifier.createInterleaved(CMYK, new int [] {0, 1, 2, 3, 4}, true, false);
assertEquals(5, spec.getNumBands());
assertEquals(5, spec.getNumComponents());
assertEquals(32, spec.getBitsPerBand(0));
assertEquals(32, spec.getBitsPerBand(1));
assertEquals(32, spec.getBitsPerBand(2));
assertEquals(32, spec.getBitsPerBand(3));
assertEquals(32, spec.getBitsPerBand(4));
assertThat(spec.getColorModel(), is(ComponentColorModel.class));
assertTrue(spec.getColorModel().hasAlpha());
assertFalse(spec.getColorModel().isAlphaPremultiplied());
assertEquals(5, spec.getColorModel().getNumComponents());
assertEquals(4, spec.getColorModel().getNumColorComponents());
assertThat(spec.getSampleModel(), is(PixelInterleavedSampleModel.class));
assertEquals(5, spec.getSampleModel().getNumBands());
assertEquals(5, spec.getSampleModel().getNumDataElements());
}

推荐阅读
  • 本文探讨了如何使用Scrapy框架构建高效的数据采集系统,以及如何通过异步处理技术提升数据存储的效率。同时,文章还介绍了针对不同网站采用的不同采集策略。 ... [详细]
  • 一、使用Microsoft.Office.Interop.Excel.DLL需要安装Office代码如下:2publicstaticboolExportExcel(S ... [详细]
  • Python网络编程:深入探讨TCP粘包问题及解决方案
    本文详细探讨了TCP协议下的粘包现象及其产生的原因,并提供了通过自定义报头解决粘包问题的具体实现方案。同时,对比了TCP与UDP协议在数据传输上的不同特性。 ... [详细]
  • Gradle 是 Android Studio 中默认的构建工具,了解其基本配置对于开发效率的提升至关重要。本文将详细介绍如何在 Gradle 中定义和使用共享变量,以确保项目的一致性和可维护性。 ... [详细]
  • Java多线程售票案例分析
    本文通过一个售票系统的实例,深入探讨了Java中的多线程技术及其在资源共享和并发控制中的应用。售票过程涉及查询、收款、找零和出票等多个步骤,其中对总票数的管理尤为关键。 ... [详细]
  • 本文详细介绍如何在SSM(Spring + Spring MVC + MyBatis)框架中实现分页功能。包括分页的基本概念、数据准备、前端分页栏的设计与实现、后端分页逻辑的编写以及最终的测试步骤。 ... [详细]
  • 本文基于Java官方文档进行了适当修改,旨在介绍如何实现一个能够同时处理多个客户端请求的服务端程序。在前文中,我们探讨了单客户端访问的服务端实现,而本篇将深入讲解多客户端环境下的服务端设计与实现。 ... [详细]
  • 1、编写一个Java程序在屏幕上输出“你好!”。programmenameHelloworld.javapublicclassHelloworld{publicst ... [详细]
  • Asynchronous JavaScript and XML (AJAX) 的流行很大程度上得益于 Google 在其产品如 Google Suggest 和 Google Maps 中的应用。本文将深入探讨 AJAX 在 .NET 环境下的工作原理及其实现方法。 ... [详细]
  • 使用Matlab创建动态GIF动画
    动态GIF图可以有效增强数据表达的直观性和吸引力。本文将详细介绍如何利用Matlab软件生成动态GIF图,涵盖基本代码实现与高级应用技巧。 ... [详细]
  • Hibernate全自动全映射ORM框架,旨在消除sql,是一个持久层的ORM框架1)、基础概念DAO(DataAccessorOb ... [详细]
  • 题目描述:Balala Power! 时间限制:4000/2000 MS (Java/Other) 内存限制:131072/131072 K (Java/Other)。题目背景及问题描述详见正文。 ... [详细]
  • 本文详细介绍了如何使用C#实现不同类型的系统服务账户(如Windows服务、计划任务和IIS应用池)的密码重置方法。 ... [详细]
  • 基于SSM框架的在线考试系统:随机组卷功能详解
    本文深入探讨了基于SSM(Spring, Spring MVC, MyBatis)框架构建的在线考试系统中,随机组卷功能的设计与实现方法。 ... [详细]
  • 深入解析 C++ 中的 String 和 Vector
    本文详细介绍了 C++ 编程语言中 String 和 Vector 的使用方法及特性,旨在帮助开发者更好地理解和应用这两个重要的容器。 ... [详细]
author-avatar
xXxHolicxXx900
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有