托管C++ 图像快速读取
来源:互联网 发布:淘宝手机端店铺公告 编辑:程序博客网 时间:2024/05/16 12:39
基于GetPixel 和 SetPixel 速度实在是太慢,处理大点的图片几乎崩溃的速度,幸好有解决方案~
Bitmap^ bmp = gcnew Bitmap( "y.bmp" );
Rectangle rect = Rectangle(0,0,bmp->Width,bmp->Height);
System::Drawing::Imaging::BitmapData^ bmpData = bmp->LockBits( rect, System::Drawing::Imaging::ImageLockMode::ReadWrite, bmp->PixelFormat );
// Get the address of the first line.
IntPtr ptr = bmpData->Scan0;
// Declare an array to hold the bytes of the bitmap.
// This code is specific to a bitmap with 24 bits per pixels.
int bytes = bmpData->Stride * bmp->Height ;
array<Byte>^rgbValues = gcnew array<Byte>(bytes);
// Copy the RGB values into the array.
// System::Runtime::InteropServices::Marshal::Copy( ptr, rgbValues, 0, bytes );
int PixelSize=3;
// Set every third value to 255.
for ( int y = 0; y < bmp->Height; y++ )
{
for ( int x = 0; x < bmp->Width; x ++ )
{
rgbValues[bmpData->Stride * y + 3*x] = 200;
rgbValues[bmpData->Stride * y + 3*x + 1] = 200;
rgbValues[bmpData->Stride * y + 3*x + 2] = 200;
}
}
// Copy the RGB values back to the bitmap
System::Runtime::InteropServices::Marshal::Copy( rgbValues, 0, ptr, bytes );
// Unlock the bits.
bmp->UnlockBits( bmpData );
picBox->Image = bmp;
String^ filename = L"a.jpg";
bmp->Save(filename);
- 托管C++ 图像快速读取
- C语言读取BMP图像数据(转)
- 使用C函数读取BMP格式图像
- C/C++ 图像二进制存储与读取
- C/C++ 图像二进制存储与读取
- 纯c语言读取BMP图像
- C#,大文件读取时快速定位,部分读取
- Git托管代码快速入门
- 托管C 概述
- 托管C++.NET问题
- 什么是托管C++?
- 托管C++,登陆窗体
- C#中的托管代码
- 什么是托管C++?
- C++/CLI托管
- system verilog与c语言接口读取yuv图像序列
- C语言读取BMP图像到数组,BMP图片格式
- 读取图像数据的C实现(.raw存储格式)
- 第一次在这里写东西
- linux中模块的增添和删除
- windows环境下apache死机问题的解决一例
- 【转】 前ARM中国总裁谭军加盟杰得微电子
- 日志级别的选择:Debug、Info、Warn、Error还是Fatal?
- 托管C++ 图像快速读取
- 有哲理的歌词
- 从字符串转数字
- 测试网页速度 用YSlow网站策划维护工具
- 将不满_numBits位的字符串用0补全
- 获取字符串中特殊字符的个数
- C#学习笔记——委托
- linux批量重命名方法
- Tomcat 5常用优化和配置