我需要将8位IplImage转换为32位IplImage.使用来自整个网络的文档,我尝试了以下方法:
// general code
img2 = cvCreateImage(cvSize(img->width, img->height), 32, 3);
int height = img->height;
int width = img->width;
int channels = img->nChannels;
int step1 = img->widthStep;
int step2 = img2->widthStep;
int depth1 = img->depth;
int depth2 = img2->depth;
uchar *data1 = (uchar *)img->imageData;
uchar *data2 = (uchar *)img2->imageData;
for(h=0;h<height;h++) for(w=0;w<width;w++) for(c=0;c<channels;c++) {
// attempt code...
}
// attempt one
// result: white image, two red spots which appear in the original image too.
// this is the closest result, what's …Run Code Online (Sandbox Code Playgroud) 我正在尝试在两个图像上应用混合滤镜(在本例中为HardLight).基础Android库不支持HardLight,因此,我在每个像素上手动完成.第一次运行正在运行,但速度低于恒星.从基础500x500图像和500x500过滤器生成500x500图像的过程太长了.这段代码也用于生成缩略图(72x72),它与应用程序的核心不可分割.我喜欢一些关于如何提高速度的建议和/或提示.
如果假设两个图像都不具有alpha,那么可以获得巨大的收益,这很好.注意:BlendMode和alpha是示例中未使用的值(BlendMode将选择混合类型,在本例中为硬编码HardLight).
public Bitmap blendedBitmap(Bitmap source, Bitmap layer, BlendMode blendMode, float alpha) {
Bitmap base = source.copy(Config.ARGB_8888, true);
Bitmap blend = layer.copy(Config.ARGB_8888, false);
IntBuffer buffBase = IntBuffer.allocate(base.getWidth() * base.getHeight());
base.copyPixelsToBuffer(buffBase);
buffBase.rewind();
IntBuffer buffBlend = IntBuffer.allocate(blend.getWidth() * blend.getHeight());
blend.copyPixelsToBuffer(buffBlend);
buffBlend.rewind();
IntBuffer buffOut = IntBuffer.allocate(base.getWidth() * base.getHeight());
buffOut.rewind();
while (buffOut.position() < buffOut.limit()) {
int filterInt = buffBlend.get();
int srcInt = buffBase.get();
int redValueFilter = Color.red(filterInt);
int greenValueFilter = Color.green(filterInt);
int blueValueFilter = Color.blue(filterInt);
int redValueSrc = Color.red(srcInt);
int greenValueSrc = …Run Code Online (Sandbox Code Playgroud) 我的目标是将PDF转换为图像(特别是在TIFF中)。
有一个名为BitsPerComponent的PDF属性
根据页面上的描述,
此属性的值可以为1、2、4、8或16。PDF规范中不支持其他值。
意思,1,2,4,8点或16转换为在图像每个像素的位数?