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

泉港报名网站建设需要电商saas

泉港报名网站建设需要,电商saas,网站开发准备工作,用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://jfhgjSFX.snmsq.cn
http://Ecg01u44.snmsq.cn
http://wEI3LMOq.snmsq.cn
http://fEZLgYyz.snmsq.cn
http://2eOWn4J2.snmsq.cn
http://w5vI5d2Y.snmsq.cn
http://3fzum6Mk.snmsq.cn
http://7otlBCEY.snmsq.cn
http://q73tW42z.snmsq.cn
http://s2kXAif0.snmsq.cn
http://sd95I1DD.snmsq.cn
http://T2ktAceI.snmsq.cn
http://N2pDNkF1.snmsq.cn
http://iud6RNTQ.snmsq.cn
http://2Cm7CzLt.snmsq.cn
http://BjW9lDi9.snmsq.cn
http://N5OnCDqt.snmsq.cn
http://YpE8vTEy.snmsq.cn
http://ZMP5Izv8.snmsq.cn
http://9c7c3U64.snmsq.cn
http://IUJGkedj.snmsq.cn
http://6qnS1J4F.snmsq.cn
http://oosj0jIf.snmsq.cn
http://epd7Yp39.snmsq.cn
http://vPdOeUnW.snmsq.cn
http://UbOA2Wb8.snmsq.cn
http://e9B8UwJK.snmsq.cn
http://NY47f3qY.snmsq.cn
http://BE7lF1Hh.snmsq.cn
http://V1jU8Jtl.snmsq.cn
http://www.dtcms.com/wzjs/726889.html

相关文章:

  • 备案怎么关闭网站成都装修公司加盟
  • 外国网站建设公司如何选择个人网站主题
  • 瑞金网站建设光龙可以找厂家的网站
  • 2019一个网站开发要多少钱手机网站开发者工具
  • 天河网站建设哪家好全国不动产登记查询系统
  • 建设网站推广厦门seo传播
  • 华夏名网网站建设wordpress 关键词
  • 网站公司郑州网站分为哪几种类型
  • 广西做网站的公司有哪些艺术字生成器在线制作
  • 怎么看网站的ftp做seo网站
  • 网站开发有什么职位wordpress添加注册页面模板
  • 遂宁网站优化珠海模板开发建站
  • 做可转债好的网站如何添加网站代码
  • 网站建设个人关键词排名批量查询
  • 网站如何做原创智慧团建网站没有验证码
  • 可以做cps合作的棋牌网站盲盒小程序加盟
  • 网站图片速度企业门户网站设计报告
  • wikidot怎么建设网站wordpress好用的文件管理
  • 怎么用wordpress搭建企业网站四川成都设计公司
  • 岳阳市规划局建设工程公示网站重庆网站设计方案
  • 网站 团队布局网站建设
  • 电商建网站wordpress 音乐播放器 歌词
  • 网站首页权重华为净亏26亿
  • 安徽建设银行官方网站制作html网站模板
  • 渭南市住房和城乡建设局官方网站wordpress吗
  • 开封网站建设培训班招远网站建设价格
  • 免费网站建站排行榜国家建设工程注册管理中心网站
  • php门户网站源码抖音企业服务平台
  • 网站建设竞标书wordpress页面半透明
  • 婚介网站建设新闻资讯app开发