当前位置:网站首页>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();
边栏推荐
猜你喜欢
随机推荐
Talk about routing design in service governance
Hackers use new PowerShell backdoors in log4j attacks
深度学习------不同方法实现lenet-5模型
three. Solution to stripe shadow and grid shadow in JS
C#打印缩放
Hcip Road
Imperva- method of finding regular match timeout
转盘式视觉筛选机及其图像识别系统
通过端口查文件
Matlab random volatility SV, GARCH using MCMC Markov chain Monte Carlo method to analyze exchange rate time series
职场必备的30套报表模板,满足95%的报表需求,一键套用无需代码
Capturing packets to find repeated acks and a large number of TCP retransmissions in TCP sessions -- sack (selective acknowledgement) technology
QT project error: -1: error: cannot run compiler 'clang++' Output:mingw32-make. exe
1278_FreeRTOS_借助prvAddCurrentTaskToDelayedList接口理解delayed task
Mathematical knowledge: fast power fast power
建立一有序的顺序表,并实现下列操作: 1.把元素x插入表中并保持有序; 2.查找值为x的元素,若找到将其删除; 3.输出表中各元素的值。
Socket socket programming
Qt工程报错:-1: error: Cannot run compiler ‘clang++‘. Output:mingw32-make.exe
数学知识:快速幂求逆元—快速幂
数学知识:欧拉函数—欧拉函数
![[veusz] import 2D data in CSV](/img/22/467139f5a83ce9e88a57ced732d4d6.png)







