当前位置:网站首页>Copy image bitmap by C # memory method
Copy image bitmap by C # memory method
2022-06-23 07:59:00 【pcjiushizhu】
/**
* Memory method to copy pictures
* */
private void copyBitmap(Bitmap bmpSrc, Bitmap bmpDest)
{
int w = bmpSrc.Width, h = bmpSrc.Height;
PixelFormat format = bmpSrc.PixelFormat;
// Lock the bitmap's bits. Lock bitmap
Rectangle rect = new Rectangle(0, 0, w, h);
BitmapData bmpDataSrc =
bmpSrc.LockBits(rect, ImageLockMode.ReadOnly,
format);
// Get the address of the first line. Get the first line address
IntPtr ptrSrc = bmpDataSrc.Scan0;
BitmapData bmpDataDest =
bmpDest.LockBits(rect, ImageLockMode.WriteOnly,
format);
IntPtr ptrDest = bmpDataDest.Scan0;
// Declare an array to hold the bytes of the bitmap. Define an array to hold bitmaps
int bytes = Math.Abs(bmpDataSrc.Stride) * h;
byte[] rgbValues = new byte[bytes];
// Copy the RGB values into the array. Copy RGB Value to array
System.Runtime.InteropServices.Marshal.Copy(ptrSrc, rgbValues, 0, bytes);
// Copy to new diagram
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptrDest, bytes);
// Unlock the bits. Unlock
bmpSrc.UnlockBits(bmpDataSrc);
bmpDest.UnlockBits(bmpDataDest);
}
// Pay attention to bmpSRC.Dispose();
边栏推荐
- INT 104_LEC 06
- The road to hcip MPLS
- Create an orderly sequence table and perform the following operations: 1 Insert element x into the table and keep it in order; 2. find the element with the value of X, and delete it if found; 3. outpu
- Sequence table Curriculum
- Quickly delete the node in the code_ modules
- 深度学习------不同方法实现lenet-5模型
- Check the file through the port
- Microsoft Exchange – prevent network attacks
- HCIP之路第八次实验
- Deploy kubersphere in kubernetes
猜你喜欢

Qt 使用QDomDocument读取xml文件

PHP 文件包含 -ctf

深度学习------不同方法实现vgg16

HCIP之路MPLS

Friends of the week

某年某月某公司的面试题(1)

Start appium

The road to hcip MPLS

《一周的朋友》

Create an orderly sequence table and perform the following operations: 1 Insert element x into the table and keep it in order; 2. find the element with the value of X, and delete it if found; 3. outpu
随机推荐
MySQL获取系统时间段
Take you to tiktok. That's it
For loop of go language foundation
SQL注入常用到的绕过方式-ctf
@What is the difference between controller and @restcontroller?
在kubernetes中部署kubersphere
firewalld 配置文件的位置
Check the file through the port
【Kubernetes】Kubernetes各大版本的最新版本下载地址
How do I install MySQL on my computer?
论文伪代码规范,伪代码在线编辑器,
On ThreadLocal and inheritablethreadlocal, source code analysis
【markdown】markdown 教程大归纳
Active Directory之AD对象
Learn to draw Er graph in an article
socket编程(多线程)
Introduction to Excel VBA and practical examples
【Try to Hack】ip地址
Imperva- method of finding regular match timeout
浅析 Open API 设计规范