博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转][Magick++] How to convert jpg image to raw 32 bit float
阅读量:2435 次
发布时间:2019-05-10

本文共 1008 字,大约阅读时间需要 3 分钟。

最近一直在关注Magick++的使用,在官方论坛里看到了一些比较实际的问题。特记录于此。

 

转自 http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=16625

 

是一些参考性的代码,有助于深入理解Magick++

 

 

int _tmain(int argc, _TCHAR* argv[]) {

   Geometry g(800, 533);
   Image theI;
   FILE* fh;
   float *floatPixelMap;
   try {
      theI.read(g, "./bluejay.jpg");
      int height = theI.rows();
      int width = theI.columns();
      int size = height * width * 4;
      PixelPacket* myMap = theI.getPixels(0, 0, width, height);
      floatPixelMap = new float[size];
      for (int counter = 0, k=0; counter < size; counter++, ++k) {
         floatPixelMap[counter++]  = (float)myMap[k].red      / 255.0f;
         floatPixelMap[counter++]  = (float)myMap[k].green    / 255.0f;
         floatPixelMap[counter++]  = (float)myMap[k].blue     / 255.0f;
         floatPixelMap[counter]    = (float)myMap[k].opacity  / 255.0f;
      }//end for loop
      fh = fopen("./bluejay32float.procd.rgba", "wb");
      fwrite((void *)floatPixelMap, sizeof(float), size, fh);
   }//end try block
   catch(Exception& ex) {
      cout << "imagicktstr,error," << ex.what() << endl;
   }//end catch block
   return 0;
}//end main

转载地址:http://zagmb.baihongyu.com/

你可能感兴趣的文章
Hibernate单向关联N-1
查看>>
Hibernate单向关联1-1
查看>>
jQuery自定义动画
查看>>
Spring-data-redis在shiro中的实例
查看>>
GUN C中__attribute__作用
查看>>
3、系统调用之SYSCALL_DEFINE分析
查看>>
linux的signal_pending及signal
查看>>
OBJDUMP用法
查看>>
c/cplusplus通用makefile
查看>>
JavaScript-密码强度
查看>>
【SSH】1366-InCorrect string value:'\xE9\x99\x88\xE6\x96\xB0...'for column 'name' at row 1
查看>>
SpringCloud前身之微服务
查看>>
纵览全局——SSH
查看>>
Mybatis-略识之无
查看>>
[Vue warn]: Property or method "name" is not defined on the instance but referenced during render
查看>>
ts:json串转换成数组
查看>>
String、StringBuffer和StringBuilder的区别
查看>>
java——职责链模式
查看>>
java_选择类排序——简单选择排序
查看>>
java_中介者模式
查看>>