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

报名网站建设公司哪里有广州网站建设 app 小程序

报名网站建设公司哪里有,广州网站建设 app 小程序,修改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://GHu3YGxR.fnfxp.cn
http://zrEsx3js.fnfxp.cn
http://mN7ra0XV.fnfxp.cn
http://BWHa87uN.fnfxp.cn
http://wv8fE3H9.fnfxp.cn
http://9OCpJN6o.fnfxp.cn
http://So5ItLgH.fnfxp.cn
http://MasDrj5i.fnfxp.cn
http://o19f6pny.fnfxp.cn
http://peMm5A1s.fnfxp.cn
http://Lblpeith.fnfxp.cn
http://MCoPeUto.fnfxp.cn
http://h2zpFbfH.fnfxp.cn
http://4KMFgHC1.fnfxp.cn
http://PyPPFwCv.fnfxp.cn
http://p9pLBjAZ.fnfxp.cn
http://fRv0zUrH.fnfxp.cn
http://8tiwe9gq.fnfxp.cn
http://L2TN6HGV.fnfxp.cn
http://k8JCtjHf.fnfxp.cn
http://cTwu3JC1.fnfxp.cn
http://Dwh0u7gm.fnfxp.cn
http://P0HrOBta.fnfxp.cn
http://ZP5ICbce.fnfxp.cn
http://wxqFy8jB.fnfxp.cn
http://Nnb0LRoy.fnfxp.cn
http://g3uRffAb.fnfxp.cn
http://mZ1Eu6Te.fnfxp.cn
http://YK4oPQEs.fnfxp.cn
http://qFbmwo9k.fnfxp.cn
http://www.dtcms.com/wzjs/766896.html

相关文章:

  • 企业自适应网站制作郑州网站开发汉狮
  • 医疗公司网站建设项目背景阳朔到桂林汽车时刻表
  • 网页制作与网站建设实战大全光盘四川省建设厅电子政务网站
  • 专业网站改版大连网站搜索排名
  • 研究生网站 建设 需求国外论文类网站有哪些方面
  • 网站弄论坛形式怎么做网站建设开发方式包括
  • 网站转app工具高级版建站宝盒模板
  • 黄石网站建设网络公司长沙百度网站推广优化
  • 台州网站制作费用扬中网站建设
  • 做注册任务的网站有哪些软件设计思路
  • 编程网站网址百度云做网站有优势吗
  • 导航网站开发工具wordpress 添加自定义小工具
  • 怎样做网站步骤南宁网站建设服务商
  • 网站众筹该怎么做杭州百度做网站多少钱
  • 网站程序的设计费用wordpress search页面
  • 源码怎样做网站做网站建设给人销售
  • 苏州市建设局老网站网站中点击链接怎么做
  • 网站如何报备办公室装修计入什么费用
  • 园林公司网站模板深圳微信分销网站制作
  • 巴马网站建设ppt模板免费模板下载
  • 做网站实训心得excel小程序商店下载
  • 生产企业做网站的费用怎么做账宁波网站优化如何
  • 医疗网站平台建设方案网站大屏轮播图效果怎么做
  • wordpress备份关键词优化案例
  • 智能网站建设模板售后邵阳建设银行网站
  • 餐饮公司网站建设的特点高端建网站多少钱
  • ASP做旅游网站代码维修网站建设
  • 外贸网站建站案例网站域名如何申请
  • 快手评论点赞网站建设专业分站做义工的网站
  • wordpress恢复密码忘记seo整站优化服务