在PDF页面上呈现图像
Rendering an image on a PDF page
我正在尝试创建和渲染PDF页面中的图像。我使用PDEImageCreate API来创建一个PDEImage
对象,然后在PDPage
的PDEContent
中设置这个对象。
但是,我无法在页面上呈现正确的图像。我正在发送原始数据作为输入并使用DeviceRGB
颜色空间。下面是我使用的代码的快照:
unsigned char* mImageDataBuffer;
mImageDataBuffer = (unsigned char*)ASmalloc((ASSize_t)30000);
imageAttrs.bitsPerComponent = 8;
imageAttrs.flags = kPDEImageIsMask;
imageAttrs.width = 100;
imageAttrs.height = 100;
imageAttrs.intent = ASAtomNull;
imageMatrix.a = ASFloatToFixed(500.0);
imageMatrix.b = fixedZero;
imageMatrix.c = fixedZero;
imageMatrix.d = ASFloatToFixed(500.0);
imageMatrix.h = fixedZero;
imageMatrix.v = fixedZero;
for (int i = 0; i < 30000;)
{
mImageDataBuffer[i++] = 0x00;
mImageDataBuffer[i++] = 0x00;
mImageDataBuffer[i++] = 0x0f;
}
PDEColorValueP pdeColorValue = (PDEColorValueP)ASmalloc(sizeof(PDEColorValue));
memset(pdeColorValue, 0, sizeof(PDEColorValue));
pdeColorValue->color[0] = FloatToASFixed(255.0f);
pdeColorValue->color[1] = FloatToASFixed(0.0f);
pdeColorValue->color[2] = FloatToASFixed(0.0f);
pdeImage = PDEImageCreate(&imageAttrs, (Uns32)sizeof(imageAttrs), &imageMatrix, 0, PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")),
pdeColorValue, NULL, 0, mImageDataBuffer, 0);
主要有两个问题我无法找出原因——
我尝试在mimagedatbuffer中放置随机值,如果在页面上渲染任何东西,它总是黑色和白色。
如果数据缓冲区的一个字节是
0x00
,那么如果其余字节非零,Acrobat将抛出错误消息。
最后一个参数不应该是mImageDataBuffer
的大小吗?例如:
pdeImage = PDEImageCreate(&imageAttrs, (Uns32)sizeof(imageAttrs), &imageMatrix, 0, PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB")),
pdeColorValue, NULL, 0, mImageDataBuffer, 30000);
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 平均图像时图像损坏
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 如何将图像传输到c++(dll)中的缓冲区,然后在c#的缓冲区中读/写
- Vulkan验证层不断在VkQueuePresentKHR()上抛出图像布局错误
- 使用FFMPEG将RGB图像序列保存到.mp4时出现问题
- 将RGB图像保存为PPM格式
- 将图像添加到资源文件夹UWP C++
- 彩色图像的卤化物处理平均值
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 如何使用我的C程序将PDF转换为图像格式(jpeg,png,..)
- 在Qt中使用将pdf图像转换为jpg图像
- 在Windows 8.1上使用MuPDF创建pdf的图像注释
- 在 jpeg/bmp/pdf 图像中搜索直线、圆圈和文本
- 为什么我的libharu pdf过大,带有.png图像
- 在PDF页面上呈现图像
- 是否有任何Api在android为ms office word(.doc/.docx)到(图像/html/xml/pdf