- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 .bmp header 读入内存。当我运行程序时,我得到了一个核心转储。
BMP_Image *Read_BMP_Header(FILE* fptr) {
fseek(fptr, 0, SEEK_SET);
BMP_Image *bmp_image = NULL;
bmp_image = malloc(sizeof(BMP_Header));
fread(&bmp_image->header, sizeof(BMP_Header), 1, fptr);
return bmp_image;
}
读取时的错误。
header 结构为:
typedef struct _BMP_Header
{
uint16_t type; // Magic identifier
uint32_t size; // File size in bytes
uint16_t reserved1; // Not used
uint16_t reserved2; // Not used
uint32_t offset; // Offset to image data in bytes from beginning of file (54 bytes)
uint32_t DIB_header_size; // DIB Header size in bytes (40 bytes)
int32_t width; // Width of the image
int32_t height; // Height of image
uint16_t planes; // Number of color planes
uint16_t bits; // Bits per pixel
uint32_t compression; // Compression type
uint32_t imagesize; // Image size in bytes
int32_t xresolution; // Pixels per meter
int32_t yresolution; // Pixels per meter
uint32_t ncolours; // Number of colors
uint32_t importantcolours; // Important colors
} BMP_Header;
图像结构为:
typedef struct _BMP_Image {
BMP_Header header;
unsigned char *data;
} BMP_Image;
最佳答案
你的主要问题是
bmp_image = malloc(sizeof(BMP_Header));
应该是
bmp_image = malloc(sizeof(BMP_Image));
这样就可以避免这种错误
bmp_image = malloc(sizeof(*bmp_image));
失败的原因可能有很多,但这肯定是错误的,因为您正在为 BMP_Header *
分配空间,但用 BMP_Image *
指向它,这是不同尺寸的结构。取消引用指针将成为未定义的行为,因为您无法保证给定的行为。
关于c - 将 C bmp 读入内存时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33558052/
正如标题中所描述的那样。代码如下所示 #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
我是一名优秀的程序员,十分优秀!