如何为像素着色? [英] How to color a pixel?

查看:120
本文介绍了如何为像素着色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须创建一个简单的2D动画,而无需使用各种图元线条,圆等来达到此目的。它必须通过操纵像素,并通过着色像素来实现用于绘制线条,圆形等的算法之一来完成。



我想到了使用Turbo C的目的,但我使用Ubuntu的。所以我尝试使用dosbox安装并运行turbo C,但无济于事。

现在我唯一的选择是Java。有没有可能在Java中操纵像素?我找不到任何相同的好教程。如果可以给出相同的示例代码,那将是非常好的。 java.awt.BufferedImage 有一个设置单个像素颜色的方法 setRGB(int x,int y,int rgb)。此外,您可能需要查看 java.awt.Color ,特别是它的 getRGB()方法,它可以将Colors转换为可以放入整数的整数 setRGB int rgb 参数。


I have to create a simple 2D animation without using various primitives for drawing line, circle etc for the purpose. It has to be done by manipulating pixels and implementing one of the algorithms for drawing line, circle etc by coloring pixels.

I thought of using Turbo C for the purpose, but I use ubuntu. So I tried using dosbox to install and run turbo C but to no avail.

Now my only option is Java. Is it possible to manipulate pixels in Java? I couldn't find myself any good tutorials for the same. It would be great if a sample code for the same can be given.

解决方案

The class java.awt.BufferedImage has a method setRGB(int x, int y, int rgb) which sets the color of an individual pixel. Additionally, you might want to look at java.awt.Color, especially its getRGB() method, which can convert Colors into integers that you can put into the int rgb parameter of setRGB.

这篇关于如何为像素着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆