本文告诉大家在 DirectX 9 的颜色格式 Format 和 WPF 的 PixelFormat 转换方法 转换代码如下 private static PixelFormat TranslateFormatToPixelFormat NotSupportedException(), }; } 值得一说的是 SharpDx 当前官方不维护了,可以选择的代替请看 SharpDx 的代替项目 在 WPF 的 PixelFormat
}, { AV_PIX_FMT_RGB444, SDL_PIXELFORMAT_RGB444 }, { AV_PIX_FMT_RGB555, SDL_PIXELFORMAT_RGB555 }, { AV_PIX_FMT_BGR555, SDL_PIXELFORMAT_BGR555 }, { AV_PIX_FMT_RGB565, SDL_PIXELFORMAT_RGB565 }, { AV_PIX_FMT_BGR565, SDL_PIXELFORMAT_BGR565 }, { AV_PIX_FMT_RGB24, SDL_PIXELFORMAT_RGB24 }, { AV_PIX_FMT_BGR24, SDL_PIXELFORMAT_BGR24 }, { AV_PIX_FMT_0RGB32, SDL_PIXELFORMAT_RGB888 }, { AV_PIX_FMT_YUYV422, SDL_PIXELFORMAT_YUY2 }, { AV_PIX_FMT_UYVY422, SDL_PIXELFORMAT_UYVY
this pixelformat name = YUV420 [CAMERA_DEBUG] fo[ 63.546341] [VIN_ERR]vin is not support this pixelformat VIN_ERR]vin is not support this pixelformat [ 81.029406] [VIN_ERR]vin is not support this pixelformat this pixelformat [ 81.048112] [VIN_ERR]vin is not support this pixelformat [ 81.054244] [VIN_ERR ]vin is not support this pixelformat [ 81.060641] [VIN_ERR]vin is not support this pixelformat [ pixelformat [ 81.079441] [VIN_ERR]vin is not support this pixelformat [ 81.085738] [VIN_ERR]vin
cloneFrame.bytesPerLine(); //qDebug()<<"mappedBytes:"<<cloneFrame.mappedBytes(); //qDebug()<<"pixelFormat :"<<cloneFrame.pixelFormat(); unsigned char rgb_buffer[VIDEO_WIDTH*VIDEO_HEIGHT*3]; if(cloneFrame.pixelFormat TO_RGB24(cloneFrame.bits(),rgb_buffer,cloneFrame.width(),cloneFrame.height()); } else if(cloneFrame.pixelFormat yuyv_to_rgb(cloneFrame.bits(),rgb_buffer,cloneFrame.width(),cloneFrame.height()); } else if(cloneFrame.pixelFormat =image.rgbSwapped(); //BGR格式转RGB image=image.mirrored(false, true); } if(cloneFrame.pixelFormat
if (image == null) { throw new ArgumentNullException("image"); } if ((image.PixelFormat & PixelFormat.Indexed) ! = PixelFormat.Undefined) { throw new Exception(SR.GetString("GdiplusCannotCreateGraphicsFromIndexedPixelFormat PixelFormat4bppIndexed PixelFormat8bppIndexed PixelFormat16bppGrayScale PixelFormat16bppARGB1555 == false) { Bmp.Dispose(); throw new Exception("Wrong PixelFormat
创建 RenderTargetProperties 需要参数 PixelFormat ,请看下面 var pixelFormat = new D2D.PixelFormat var renderTargetProperties = new D2D.RenderTargetProperties(D2D.RenderTargetType.Default, pixelFormat D2D.RenderTargetUsage.None, D2D.FeatureLevel.Level_DEFAULT); RenderTargetProperties 需要的参数是 RenderTargetType ,PixelFormat Loaded += (s, e) => { var factory = new D2D.Factory(); var pixelFormat var renderTargetProperties = new D2D.RenderTargetProperties(D2D.RenderTargetType.Default, pixelFormat
这个问题在外网也有一些讨论,我倾向的说法是,XP的GDI+组件存在问题,对于像素格式PixelFormat有点特别的图像,把它绘制到其它地方的时候处理不好ImageAttributes,于是引发异常。 解决思路,既然同时满足这两者会报错: g.DrawImage(PixelFormat特别的Image, xxx, imageAttributes) 那么只要错开其一就行,比如这两种就不会报: g.DrawImage (常规Image, xxx, imageAttributes); //方法一 g.DrawImage(PixelFormat特别的Image, xxx); //方法二,不使用imageAttributes
tempgif.LockBits(New Rectangle(0, 0, tempgif.Width, tempgif.Height), ImageLockMode.ReadOnly, tempgif.PixelFormat 'tempgif.Palette = pal Dim outgif As New Bitmap(tempgif.Width, tempgif.Height, PixelFormat.Format8bppIndexed = outgif.LockBits(New Rectangle(0, 0, outgif.Width, outgif.Height), ImageLockMode.WriteOnly, outgif.PixelFormat
DISPLAYCONFIG_SOURCE_MODE { public int width; public int height; public DISPLAYCONFIG_PIXELFORMAT pixelFormat; public POINTL position; } [StructLayout(LayoutKind.Sequential, CharSet public uint videoStandard; public uint scanLineOrdering; } private enum DISPLAYCONFIG_PIXELFORMAT { DISPLAYCONFIG_PIXELFORMAT_8BPP = 1, DISPLAYCONFIG_PIXELFORMAT_16BPP = 2, DISPLAYCONFIG_PIXELFORMAT_24BPP = 3, DISPLAYCONFIG_PIXELFORMAT_32BPP = 4, DISPLAYCONFIG_PIXELFORMAT_NONGDI
FreeImage_Load(fif, FileName, 0); int Bpp = FreeImage_GetBPP(Dib); PixelFormat ; break; case 4: PF = PixelFormat.Format4bppIndexed; break ; case 8: PF = PixelFormat.Format8bppIndexed; break; case 16: PF = PixelFormat.Format16bppRgb555; break; case PF = PixelFormat.Format32bppArgb; break; default: FreeImage_Free
readPixel(Position pos) 读取指定位置像素的颜色值,返回的颜色格式为PixelFormat.ARGB_8888。 resetConfig(Size size, PixelFormat pixelFormat) 重置PixelMap的大小和像素格式配置,但不会改变原有的像素数据也不会重新分配像素数据的内存,重置后图像数据的字节数不能超过 writePixel(Position pos, int color) 向指定位置像素写入颜色值,写入颜色格式为PixelFormat.ARGB_8888。 writePixels(int color) 将所有像素都填充为指定的颜色值,写入颜色格式为 PixelFormat.ARGB_8888。 = PixelFormat.ARGB_8888; initializationOptions.editable = true; PixelMap pixelMap = PixelMap.create(
******** public static double GetColorCastFactor(Bitmap Bmp) { if (Bmp.PixelFormat = PixelFormat.Format24bppRgb) throw new ArgumentException("Only Support PixelFormat24RGB format Image ."); Bitmap Lab = new Bitmap(Bmp.Width, Bmp.Height, PixelFormat.Format24bppRgb); BmpData = Bmp.LockBits(new Rectangle(0, 0, Bmp.Width, Bmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb LabData = Lab.LockBits(new Rectangle(0, 0, Lab.Width, Lab.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb
{ ... } } //使用指定像素格式来初始化(默认是auto,依据图片解码的结果来确定) bool Texture2D::initWithImage(Image *image, PixelFormat return true; } } bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, int pixelsWide, int pixelsHigh) { ... = Size((float)pixelsWide, (float)pixelsHigh); _pixelsWide = pixelsWide; _pixelsHigh = pixelsHigh; _pixelFormat = pixelFormat; _maxS = 1; _maxT = 1; //关闭alpha渐变 _hasPremultipliedAlpha = false; _hasMipmaps = mipmapsNum
src = gif.LockBits(New Rectangle(0, 0, gif.Width, gif.Height), Imaging.ImageLockMode.ReadOnly, gif.PixelFormat = gif2.LockBits(New Rectangle(0, 0, gif2.Width, gif2.Height), Imaging.ImageLockMode.WriteOnly, gif2.PixelFormat src = gif.LockBits(New Rectangle(0, 0, gif.Width, gif.Height), Imaging.ImageLockMode.ReadOnly, gif.PixelFormat = gif2.LockBits(New Rectangle(0, 0, gif2.Width, gif2.Height), Imaging.ImageLockMode.WriteOnly, gif2.PixelFormat src = gif.LockBits(New Rectangle(0, 0, gif.Width, gif.Height), Imaging.ImageLockMode.ReadOnly, gif.PixelFormat
, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888 ; renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; : case SDL_PIXELFORMAT_ABGR8888: case SDL_PIXELFORMAT_RGB888: case SDL_PIXELFORMAT_BGR888 : case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_NV12: case SDL_PIXELFORMAT_NV21: ) || (texture->format == SDL_PIXELFORMAT_YV12)); data->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12
false; } //重新打印下宽高看下是否真正设置成功 struct v4l2_pix_format pix = format.fmt.pix; quint32 pixelformat = pix.pixelformat; qDebug() << TIMEMS << "cameraWidth" << cameraWidth << "cameraHeight" << cameraHeight << "width" << pix.width << "height" << pix.height; qDebug() << TIMEMS << "pixelformat" << QString ("%1%2%3%4").arg(QChar(pixelformat & 0xFF)).arg(QChar((pixelformat >> 8) & 0xFF)).arg(QChar((pixelformat >> 16) & 0xFF)).arg(QChar((pixelformat >> 24) & 0xFF)); //重新设置宽高为真实的宽高 cameraWidth = pix.width
我在代码中给出了判断一副图像是否是灰度图像的一个函数: private bool IsGrayBitmap(Bitmap Bmp) { bool IsGray; if (Bmp.PixelFormat == PixelFormat.Format8bppIndexed) // .net中灰度首先必然是索引图像 { IsGray = true; BitmapData BmpData = Bmp.LockBits(new Rectangle(0, 0, Bmp.Width, Bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb ); Bitmap GrayBmp = new Bitmap(Bmp.Width, Bmp.Height, PixelFormat.Format8bppIndexed); GrayBmpData = GrayBmp.LockBits(new Rectangle(0, 0, GrayBmp.Width, GrayBmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed
PixelFormat属性:返回图像的像素格式. 3. Palette属性:获取和设置图像所使用的颜色调色板. 4. Height Width属性:返回图像的高度和宽度. 5. PixelFormat属性:数据的实际像素格式. 4. Scan0属性:被锁定数组的首字节地址,如果整个图像被锁定,则是图像的第一个字节地址. 5. Stride属性:步幅,也称为扫描宽度. (new System.Drawing.Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format8bppIndexed ColorPalette tempPalette; 35 using (Bitmap tempBmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format8bppIndexed System.Drawing.Rectangle(0, 0, map.Width, map.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format8bppIndexed
MemoryStream(image)) //容易出现异常 { bmImage = new Bitmap(Image.FromStream(ms)); ms.Close(); } bitmapdata //PixelFormat (new System.Drawing.Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format8bppIndexed
PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; // 选择像素格式 , 如果返回 -1 , 说明选择像素格式失败 , 一般情况下该选择是成功的 int pixelFormat = ChoosePixelFormat(dc, &pfd); // 设置像素格式 SetPixelFormat(dc, pixelFormat, &pfd); 六、设置像素格式 ---- = ChoosePixelFormat(dc, &pfd); // 设置像素格式 SetPixelFormat(dc, pixelFormat, &pfd); 七、创建并设置 OpenGL PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; // 选择像素格式 , 如果返回 -1 , 说明选择像素格式失败 , 一般情况下该选择是成功的 int pixelFormat = ChoosePixelFormat(dc, &pfd); // 设置像素格式 SetPixelFormat(dc, pixelFormat, &pfd); // 创建 OpenGL