- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我的 openGL 程序只渲染了一半的纹理。我使用以下代码加载 24 位 .bmp。
unsigned char header[54]; // Each BMP file begins by a 54-bytes header
unsigned int dataPos; // Position in the file where the actual data begins
unsigned int width, height;
unsigned int imageSize; // = width*height*3
// Actual RGB data
unsigned char * data;
std::ifstream file("fnai.bmp");
if (!file.is_open()) {
std::cout << "Could not open file: " << "C:\\Users\\Danne\\Documents\\Visual Studio 2013\\Projects\\02 - OpenGL\\BTH24.bmp "<< std::endl;
}
char c;
for (int i = 0; i < 54; i++) {
file.get(c);
header[i] = c;
}
if (header[0] != 'B' || header[1] != 'M') {
std::cout << "Incorrect or corrupt bmp file" << std::endl;
}
dataPos = *(int*)&(header[0x0A]);
imageSize = *(int*)&(header[0x22]);
width = *(int*)&(header[0x12]);
height = *(int*)&(header[0x16]);
if (imageSize == 0) {
imageSize = width*height * 3;
}
if (dataPos == 0) {
dataPos = 54;
}
data = new unsigned char[imageSize*3];
for (int i = 0; i < imageSize*3; i++) {
file.get(c);
data[i] = c;
}
file.close();
加载纹理时,纹理加载并且 openGL 接收纹理但未能完全渲染它,结果最终类似于 。
尝试不同的图像后,它在纹理的不同部分失败了。有没有人认识到这个错误?
最佳答案
我认为问题可能出在位图的位深度上。您应该尝试将其与 24 位(位深度)bmp 文件一起使用。在 photoshop 中将文件保存为 bmp 时,您可以更改位深度。我个人不知道为什么只能使用 24 位,但我建议尝试一下。
关于c++ - 从 .bmp openGL 加载纹理的奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27333275/
正如标题中所描述的那样。代码如下所示 #include #include using namespace std; #define WIDTH 90 #define HEIGHT 180 cla
我正在开发一个程序来调整 BMP 文件的大小并将其存储在一个新文件中。我注意到有些 BMP 完全颠倒存储,而其他 BMP 则只是直立存储。所以我做了两个解决方案来处理这两种情况。我的问题是如何事先知道
如何使用 ZPL II 打印位图 (BMP) 图像? 我使用 ~DY 将 BMP 下载到打印机: ~DYR:PRINT,B,B, , , 我正在使用 PHP 将原始数据发送到打印机,因此 <>
我正在尝试将彩色 BMP 文件转换为灰度 BMP。输入 bmp 是 24 位,我在输出端生成相同的 24 位 bmp,只是这次是灰度。 我使用的代码是 for(int x = 0; x < max;
正如在 this example 中所见, BMP 文件中的每个 channel (R, G, B) 接受一个输入。一个 24 位的 BMP 图像有 8 位的-R、8 位的 G 和 8 位的 B。我在
总结: 直接计算表明:一张3289 X 4570 X 32bpp的.BMP图片大约需要53MB。同样大小但24bpp的图片大约需要43MB,16bpp的图片大约需要28MB。在我的情况下,ChemDr
我有 24 位图像,我读取位图并将其转换为灰度并像 8 位一样保存。 RGBTRIPLE temp; unsigned char t; ... t = (temp.rgbtBlue * 0.114 +
我想从另一个更大的 bmp 文件中找到一个小的 bmp 文件(更大的一个是从屏幕上捕获的并称为 Sample.bmp ,小的 bmp 文件称为 Button.bmp 。事情是在比较图像时文件可以随处可
我需要使用 .bmp 类型的图像。其格式为: struct bmp_fileheader { unsigned char fileMarker1; /* 'B' */ unsigne
我正在尝试获取一个 BMP 文件并将其读入,然后对其中的像素执行操作以更改其颜色。我的问题是我无法将文件中的数据读入两个 BMP header 结构。我能够很好地将所有数据读入第一个结构,但在读入第二
这个问题已经有答案了: Why does comparing strings using either '==' or 'is' sometimes produce a different resul
我正在尝试使用以下代码将 bmp 图像转换为 jpeg。 from PIL import Image img = Image.open('/Desktop/xyz.bmp') new_img = im
在 24 位 bmp 中,像素存储为 BGR,每种颜色仅占用 1 个字节。那个可以读 for(i=0;i
我在学校有一个任务,要将水印 bmp 图像添加到其他 bmp 图像中。该任务称为 alpha 混合。我必须在用户将在启动时通过程序参数设置的特定坐标插入水印,以及水印混合的 alpha 值。我几乎成功
这是我的位图对象 Bitmap b = new Bitmap(columns, rows, PixelFormat.Format8bppIndexed); BitmapData bmd = b.Loc
我的编程平台是: Ubuntu 3.19 ImageMagick 6.7.7 编程语言:php 我的代码: $img = new Imagick($image_input_24bit_bmp); $i
这是我的函数,我根据维基百科 BITMAPINFOHEADER 使用标题 BMP。但是,我得到的文件没有任何图像...当放置填充时,该过程停止。 // Structures for header i
我正在发布一个 .NET 程序,并且正处于完善阶段。我需要在项目属性中设置图标。根据我的研究,我想创建以下像素大小的图像以适应所有图标大小:16、32、48、96、256。 我还找到了一个程序,可以将
我正在尝试从 BMP 图像创建 GD 图像资源,但是我没有运气。 有问题的 BMP 图像是用 Photoshop 创建和保存的。我也尝试了几个在网上找到的 BMP,它们给出了相同的结果。 getima
类型 FXPT2DOT30 出现在为 BMP 文件定义 struct CIEXYZ 时,根据微软提供的定义: http://msdn.microsoft.com/en-us/library/windo
我是一名优秀的程序员,十分优秀!