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

网站建设情况说明书青岛自动seo

网站建设情况说明书,青岛自动seo,wordpress用户自定义作者,网页设计代码为什么没有颜色实验结果 BitMap是bgr格式 为什么是bgr格式 ​​历史与底层图形库的依赖​​ ​​GDI/GDI 的遗留设计​​: C# 的 System.Drawing 命名空间基于 Windows 的 ​​GDI/GDI​​ 图形接口,而 GDI 在早期为了兼容某些硬件(如显卡帧缓冲&#xf…

实验结果

BitMap是bgr格式

为什么是bgr格式

  1. ​​历史与底层图形库的依赖​​
    ​​GDI/GDI+ 的遗留设计​​:
    C# 的 System.Drawing 命名空间基于 Windows 的 ​​GDI/GDI+​​ 图形接口,而 GDI 在早期为了兼容某些硬件(如显卡帧缓冲)和旧标准,采用了 ​​BGR 内存布局​​。这种格式在 Windows 系统中更高效,因为许多底层驱动和硬件优化(如 DirectDraw)默认支持 BGR。
    ​​字节顺序(Endianness)的影响​​:
    在 x86/x64 架构的小端(Little-Endian)系统中,多字节数据(如 32 位 ARGB 像素)的存储顺序是 ​​从低位到高位​​。例如:
    Format32bppArgb 的字节布局:[Blue, Green, Red, Alpha](内存地址从低到高)。
    这种布局直接映射到 CPU 和显卡的优化操作。
  2. ​​与 Windows 原生格式兼容​​
    ​​DIB(设备无关位图)的默认格式​​:
    Windows 的 DIB 格式(如 BITMAPINFOHEADER)通常使用 ​​BGR​​ 顺序,因此 Bitmap 类直接沿用这一标准,避免额外的转换开销。
    ​​与 DirectX/OpenGL 的交互​​:
    部分图形 API(如早期 DirectX)在处理纹理时也默认使用 BGR,Bitmap 的 BGR 格式可以减少数据转换步骤。

实验代码

生成一个bgr固定的图像

import cv2
import numpy as np# 定义图片尺寸(例如 200x200 像素)
height, width = 200, 200# 创建一个全黑的 BGR 图像(3通道)
bgr_img = np.zeros((height, width, 3), dtype=np.uint8)# 填充为指定的 BGR 颜色(B=255, G=10, R=100)
bgr_img[:, :] = [255, 10, 100]  # OpenCV 使用 BGR 顺序# 保存图片
cv2.imwrite("bgr_255_10_100.png", bgr_img)

形成的测试图片 bgr_255_10_100
请添加图片描述

使用c#加载

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace WindowsFormsApp1
{using System;using System.Drawing;using System.Drawing.Imaging;using System.IO;using System.Windows.Forms;public partial class Form1 : Form{public static void Bitmap2byte(Bitmap bitmap, byte[] img, int width, int height){// Lock the bitmap's bitsBitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, width, height),ImageLockMode.ReadOnly,PixelFormat.Format24bppRgb);try{// Get the address of the first lineIntPtr ptr = bmpData.Scan0;// Declare an array to hold the bytes of the bitmapint bytes = Math.Abs(bmpData.Stride) * height;// Check if the provided byte array is large enoughif (img.Length < bytes){throw new ArgumentException("Provided byte array is too small");}// Copy the RGB values into the byte arraySystem.Runtime.InteropServices.Marshal.Copy(ptr, img, 0, bytes);}finally{// Unlock the bitsbitmap.UnlockBits(bmpData);}}public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){// Test the function by loading an image from filetry{string imagePath = @"C:\YanHuaImage\bgr.png"; // Change this to your test image pathif (File.Exists(imagePath)){using (Bitmap bitmap = new Bitmap(imagePath)){int width = bitmap.Width;int height = bitmap.Height;// Calculate the required byte array sizeint bytesPerPixel = 3; // For 24bpp RGBint stride = width * bytesPerPixel;stride += (4 - (stride % 4)) % 4; // Align to 4 bytesint totalBytes = stride * height;byte[] imageBytes = new byte[totalBytes];Bitmap2byte(bitmap, imageBytes, width, height);// Display some informationMessageBox.Show($"Image loaded successfully!\n" +$"Width: {width}, Height: {height}\n" +$"Total bytes: {totalBytes}\n" +$"First pixel (BGR): {imageBytes[0]}, {imageBytes[1]}, {imageBytes[2]}");}}else{MessageBox.Show("Test image not found at: " + imagePath);}}catch (Exception ex){MessageBox.Show("Error: " + ex.Message);}}}
}
http://www.dtcms.com/wzjs/154357.html

相关文章:

  • 做企业网站 签合同要注意什么汕头网站建设方案开发
  • 天津注册公司多少钱百度seo 优化
  • 全新域名请收藏seo技术优化技巧
  • 那个网站是做房产中介的宁波网站制作与推广价格
  • 网站收录怎么弄深圳市住房和建设局
  • 外贸公司的网站建设模板下载西地那非片吃了多久会硬起来
  • 北京市专业网站制作企业营销型网站外包
  • 购物网站开发项目意义郑州网站优化公司
  • axure怎么做响应式网站北京seo优化wyhseo
  • 网易云播放器做网站播放中国十大外贸平台
  • 建设门户网站请示宁波seo快速优化
  • wordpress简单的验证码北京seo排名服务
  • 网站怎么做房源网络营销推广方案ppt
  • 怎么做车载mp3下载网站必应搜索引擎国际版
  • 果洛电子商务网站建设多少钱windows优化大师
  • 建网站到底需要多少钱深圳将进一步优化防控措施
  • 平面设计论坛重庆高端网站seo
  • 做网站复制国家机关印章社群营销平台有哪些
  • 沈阳模板建站代理百度怎样发布信息
  • 网站关键字让别人做超链接了怎么办沈阳疫情最新消息
  • 做商铺的网站有那些手机百度如何发布广告
  • 做音乐头像网站艺术培训学校招生方案
  • 网站如何增加百度权重的方法网络推广项目
  • 珠海做网站设计有哪些自助优化排名工具
  • 郑州酒店网站建设湖南网站建设推荐
  • 黄金网站软件app下载安装网站优化公司认准乐云seo
  • 日本有个做二十四节气照片的网站廊坊百度关键词优化怎么做
  • 一站式做网站公司经典软文推广案例
  • 建卡盟网站建设 网站定制开发关键词搜索热度
  • 大连网站开发公司电话东莞网络公司网络推广