分割bmp图像. [英] Split a bmp image .

查看:114
本文介绍了分割bmp图像.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我的项目是制作自己的jpg格式.

我有一个256/256 px的bmp,​​我想做的是:当我在图片内单击时,我想取8/8 px的核心对应正方形并显示在另一个pictureBox中.我需要这样做是因为我想要同时显示较小的图片和核心编码矩阵.

非常抱歉,如果您不明白我的意思,请问我,我会尽力解释这种情况.

Hello , My project is to make my own jpg format .

I have a 256/256 px bmp and what I want to do is this : when I click inside the picture I want to take the coresponding square of 8/8 px and display it in another pictureBox .I need to do this because I want to dispalay the smaller picture and the corespoding matrice in the same time.

I`am sorry for my english , If you don`t understand want I mean ask me and I will try to explain this situation better.

推荐答案

您不知道"无需创建新的图像格式.您可以裁剪现有图像并将其显示在第二个图片框中

You don''t need to create a new image format. You can crop the existing image and display it in the second picturebox

Bitmap img = new Bitmap(ExistingImage);
Bitmap cropped = img.Clone(new Rectangle(0, 0, 8, 8), bmpImage.PixelFormat);
pictureBox2.Image = cropped;


这是关键:要访问位图像素,您需要对源位图和要显示的新小位图都使用System.Drawing.Bitmap.LockBits..由于性能问题,请不要使用GetPixel/SetPixel,这一点很重要.

请参阅: http://msdn.microsoft.com/en-us/library /system.drawing.bitmap.lockbits.aspx [ http://msdn.microsoft.com/en-us/library/5ey6h79d. aspx [ ^ ].

在图片框上处理事件MouseDown;传递给您的处理程序的event arguments参数将为您提供鼠标坐标,您可以将其转换为位地址.

—SA
Here is the key: to access bitmap pixels, you need to use System.Drawing.Bitmap.LockBits. for both source bitmap and a new small bitmap you want to show. It''s important not to use GetPixel/SetPixel, due to performance problem.

Please see: http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx[^].
See the code sample here: http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx[^].

Handle the event MouseDown on your picture box; event arguments parameter passed to your handler will give you mouse coordinates which you will translate into bit address.

—SA


这篇关于分割bmp图像.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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