iPhone - 用另一个像素块替换图像中的一个像素块
我想知道是否有人可以为我指出关于哪些框架/方法的正确方向 当用另一个像素块替换图像中的一个像素块时使用。
例如,假设我有一个全红色的简单图像,我认为我的像素块大小为 5x5 像素。现在,每 3 个块我想用蓝色块(5x5 像素)替换第三个块,所以 这会产生一个红色图像,每 3 个红色块就会出现一个蓝色块。
我找到了有关像素替换的信息,但正在尝试找出如何确定和处理像素块。任何建议将不胜感激..任何代码都将是一场梦魇。
I would like to know if anyone can point me in the right direction regarding what frameworks/methods
to use when replacing a block of pixels in an image with another block of pixels.
For example lets say I have a simple image colored fully red and I consider my pixel block size as 5x5
pixels. Now every 3 blocks I want to replace the 3rd block with a blue colored block (5x5 pixels) so
that it would result in a red image with blue blocks appearing every 3 red blocks.
I've found information regarding pixel replacement but am trying to figure out how to determine and process pixel blocks. Any advice would be appreciated.. and any code would be a wet dream.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然这听起来像是一个简单的问题,但要做到这一点并不容易。您需要大量背景信息才能使一切顺利进行。它还取决于图像的来源以及您想用它做什么。
我不会为您提供一个工作示例,但这里有一些提示:
读取图像:
创建您自己的“图形上下文”以进行绘制:
将图像绘制到(当前)上下文上:
进行其他绘制:
转换位图上下文再次到图像:
然后,要么:
从视图控制器内向观众显示图像:
或者将图像写为 jpeg:
或者 PNG:
对于最后的图像,您需要有一个文件名,但事实并非如此两者都是微不足道的(考虑到您所居住的手机环境)。这是另一个你会发现很多的主题,搜索如下内容:
这是总体轮廓,我可能犯了一些错误,但这至少应该让你继续下去。
Although it may sound like a simple question, it's not quite easy to do something like that. You need a lot of background information to get everything going. It also depends on where the image comes from, and what you want to do with it.
I will not provide you with a working example, but here's some pointers:
Reading in an image:
Creating your own "graphics context" to draw on:
Painting your image onto your (current) context:
Doing some other painting:
Transforming the bitmap context to an image again:
And then, either:
Show the image to the audience, from within a view controller:
Or write the image as jpeg:
Or as PNG:
For those last ones you would need to have a filename, which is not so trivial either (given the phone environment you live in). That's another topic on which you'll find a lot, search for things like:
This is the general outline, I might have made some errors but this should get you going at least.