当前位置: 首页 > news >正文

.net winform 实现CSS3.0 泼墨画效果

效果图在这里插入图片描述
代码
private unsafe void BlendImages1(Bitmap img1, Bitmap img2)
{// 确定两个图像的重叠区域Rectangle rect = new Rectangle(0, 0,Math.Min(img1.Width, img2.Width),Math.Min(img1.Height, img2.Height));// 创建输出图像,尺寸为重叠区域大小Bitmap blendedImage = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);// Lock the bits of each image and get the BitmapData.BitmapData data1 = img1.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);BitmapData data2 = img2.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);BitmapData dataBlended = blendedImage.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);int bytesPerPixel = 4; // For Format32bppArgbint stride1 = data1.Stride;int stride2 = data2.Stride;int strideBlended = dataBlended.Stride;byte* ptr1 = (byte*)data1.Scan0.ToPointer();byte* ptr2 = (byte*)data2.Scan0.ToPointer();byte* ptrBlended = (byte*)dataBlended.Scan0.ToPointer();for (int y = 0; y < rect.Height; ++y){byte* rowPtr1 = ptr1 + y * stride1;byte* rowPtr2 = ptr2 + y * stride2;byte* rowPtrBlended = ptrBlended + y * strideBlended;for (int x = 0; x < rect.Width; ++x){int pixelOffset = x * bytesPerPixel;if (pixelOffset + bytesPerPixel <= Math.Abs(stride1) &&pixelOffset + bytesPerPixel <= Math.Abs(stride2) &&pixelOffset + bytesPerPixel <= Math.Abs(strideBlended)){rowPtrBlended[pixelOffset] = (byte)(255 - ((255 - rowPtr1[pixelOffset]) * (255 - rowPtr2[pixelOffset]) >> 8)); // BrowPtrBlended[pixelOffset + 1] = (byte)(255 - ((255 - rowPtr1[pixelOffset + 1]) * (255 - rowPtr2[pixelOffset + 1]) >> 8)); // GrowPtrBlended[pixelOffset + 2] = (byte)(255 - ((255 - rowPtr1[pixelOffset + 2]) * (255 - rowPtr2[pixelOffset + 2]) >> 8)); // RrowPtrBlended[pixelOffset + 3] = (byte)255; // A}}}// Unlock the bits of each image after processing.img1.UnlockBits(data1);img2.UnlockBits(data2);blendedImage.UnlockBits(dataBlended);// Display the blended image.pictureBoxResult.Image = blendedImage;
}

素材

在这里插入图片描述
在这里插入图片描述

http://www.lryc.cn/news/505330.html

相关文章:

  • LearnOpenGL学习(高级OpenGL - - 实例化,抗锯齿)
  • 大数据与AI:从分析到预测的跃迁
  • 【CC2530开发基础篇】继电器模块使用
  • C05S07-Tomcat服务架设
  • Java stream groupingBy sorted 实现多条件排序与分组的最佳实践
  • JAVA:代理模式(Proxy Pattern)的技术指南
  • 爬取Q房二手房房源信息
  • Ansible自动化运维(五) 运维实战
  • K-means算法的python实现
  • 客户端(浏览器)vue3本地预览txt,doc,docx,pptx,pdf,xlsx,csv,
  • [SZ901]JTAG高速下载设置(53Mhz)
  • docker springboot 运维部署详细实例
  • Linux 查看目录命令 ls 详细介绍
  • React Native状态管理器Redux、MobX、Context API、useState
  • Three.js资源-模型下载网站
  • linux 添加默认网关
  • 【学习笔记】深入浅出详解Pytorch中的View, reshape, unfold,flatten等方法。
  • CTFHUB-web(SSRF)
  • 分解质因数
  • 前景物体提取
  • Kotlin复习
  • 【AI日记】24.12.17 kaggle 比赛 2-6 | 把做饭看成一种游戏 | 咖喱牛肉
  • 操作系统(14)请求分页
  • uniapp navigateTo、redirectTo、reLaunch等页面路由跳转方法的区别
  • 模型 A/B测试(科学验证)
  • 谷歌发布升级版AI视频生成器Veo 2与图像生成器Imagen 3
  • 快速掌握源码部署Filebeat
  • C++ 哈希表封装unordered_map 和 unordered_set
  • pymysql 入门
  • Leecode刷题C++之形成目标字符串需要的最少字符串数①