[转][Magick++] How to convert jpg image to raw 32 bit float

news/2024/7/8 16:28:25 标签: float, image, exception, file

最近一直在关注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://www.niftyadmin.cn/n/1055010.html

相关文章

【git、idea】当pull遇到代码冲突该怎么办?

背景&#xff1a;昨天下午下班&#xff0c;正当我想要把编好的代码&#xff0c;上传到服务器的之前&#xff0c;pull了一下服务器的代码&#xff0c;结果被告知&#xff0c;pull fail出现了代码冲突&#xff0c;于是乎赶紧补救&#xff0c;找到了如下的方法&#xff0c;希望对大…

WinForm编程中 Enter自动登录设置

//Form窗体中的 KeyPreview ture; AcceptButton ButLogin; // ButLogin Enter控件ID名 //ok了转载于:https://www.cnblogs.com/server126/archive/2010/02/02/2290648.html

linux下查找svn的相关目录的命令

1.查询文件安装路径&#xff1a; Linux系统已经安装了SVN&#xff0c;但是不知道文件都安装在哪些地方、放在哪些文件夹里&#xff0c;可以用下面的命令查看所有的文件路径 whereis svn svn: /usr/bin/svn /usr/share/man/man1/svn.1.gz 2.查询运行文件所在路径 which svn /usr…

[转]数据类型 -- uint32_t 类型

最近在关注一个C的开源项目&#xff0c;遇到了些基础的东东&#xff0c;算是记录下来吧&#xff0c;毕竟VC上是很少遇到的。估计写博客的朋友也是从别处贴过来的。 转自 http://hi.baidu.com/zengzhaonong/blog/item/149b11f467f7d366ddc474cf.html 体会[2006-10-25]:1>. 在…

搜索 洛谷 P1434滑雪

P1434 滑雪 题目描述 Michael喜欢滑雪。这并不奇怪&#xff0c;因为滑雪的确很刺激。可是为了获得速度&#xff0c;滑的区域必须向下倾斜&#xff0c;而且当你滑到坡底&#xff0c;你不得不再次走上坡或者等待升降机来载你。Michael想知道在一个区域中最长的滑坡。区域由一个二…

SocketExceptioon关于客户端只可以收发一次的问题

之前遇到过两次&#xff0c;都是客户端忘记开了 转载于:https://www.cnblogs.com/xiaolongdejia/p/11002047.html

mysql连接jsp登陆实验效果演示

一、实验目的&#xff1a; 本实验的目的是让学生掌握怎样在JSP中连接和使用mysql中的数据。 二、实验要求&#xff1a; 编写两个JSP 页面login.jsp、和Checklogin.jsp&#xff0c;实现一个网页的正常登陆界面。具体要求如下: 1.login.jsp的具体要求&#xff1a; 用户登陆login.…

BeautifulSoup /bs4 爬虫实例

需求&#xff1a;使用bs4实现将诗词名句网站中三国演义小说的每一章的内容爬去到本地磁盘进行存储 http://www.shicimingju.com/book/sanguoyanyi.html 1 from bs4 import BeautifulSoup2 import requests3 4 url http://www.shicimingju.com/book/sanguoyanyi.html5 headers…