博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
http://daffodil.codeplex.com/
阅读量:7080 次
发布时间:2019-06-28

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

姓名(Name):3ddown.com

组织(Organization):3ddown.com

注册码(Serial):NAVJ-W56S-3YUU-MVHV

 

 

对libpsd库的一点认识

由于libpsd0.9库中没有对Photoshop6.0以上版本文字图层的读取支持,所以只能自己写了。找了很多资料,比如在adobe论坛找到的Photoshop File Formats.pdf。Photoshop6.0以上版本文字图层的格式为type tool object。如要读取它,必须用库中的psd_system.c文件,其中的psd_stream_get_int(context)为读取4个字节等等。

如上图:TySh代表type tool object。表示文字图层从这里开始。

00005670h:  00 00 00 06表示这个文字图层有6个标示(Number of items in descriptor)即有这个文字图层有6个关键字。 分别是: 第一个:"Txt " 格式"TEXT".内容:guojun。 00005670h:00 00 00 00 即“Txt ”前的4个字节都是0,表示后面的关键字为4个字节的关键字,

即是“Txt ”。注意最后有一个空格。 00005680h:00 00 00 07表示内容有7个字符,包括最后的00字符。 4个字节的关键字可以用psd_stream_get_int(context)取得。 第二个:"textGridding" 格式“enum” 变量textGridding,内容 None。 0000569h0:00 00 00 0C表示后面关键字即"textGridding"为13个字节的长度。 如果是这样,那么在程序中需要psd_stream_get(context, keychar, length); keychar[length] = 0;这样取得关键字,然后进行对比strcmp(keychar, "textGridding") == 0。

 

程序大致为这样// Number of items in descriptor number_items = psd_stream_get_int(context);

while(number_items --) {    length = psd_stream_get_int(context);    if(length == 0)     rootkey = psd_stream_get_int(context);    else    {        rootkey = 0;     psd_stream_get(context, keychar, length);     keychar[length] = 0;            }    // Type: OSType key    type = psd_stream_get_int(context);           //coutConsole1("gj");    switch(rootkey)    {      case 0:     if(strcmp(keychar, "textGridding") == 0)        {         psd_assert(type == 'enum');         // TypeID: 4 bytes (length), followed either by string or (if length is zero) 4-         // byte typeID         textgrid_length = psd_stream_get_int(context);         if (textgrid_length!=0)         {          psd_stream_get(context, keychar, textgrid_length);          keychar[textgrid_length] = 0;          if(strcmp(keychar, "textGridding") == 0)          {           int l=psd_stream_get_int(context);           if (l==0)           {          switch(psd_stream_get_int(context))          {          case 'None':           data->testgridding="n";           break;          default:              break;          }                      }                    //coutConsole1("none");          }         }                           }     else     {       if ((strcmp(keychar, "TextIndex") == 0))       {        psd_assert(type == 'long');                    coutConsole1("TextIndex");       }     }      break;              

     case 'Txt ':      // String        psd_assert(type == 'TEXT');      // String value as Unicode string       text_length = psd_stream_get_int(context);       for(i = 0; i < text_length; i ++)         data->textstring[i] = psd_stream_get_short(context) & 0x00FF;                 break;              case 'Ornt':      psd_assert(type == 'enum');      // TypeID: 4 bytes (length), followed either by string or (if length is zero) 4-      // byte typeID      length = psd_stream_get_int(context);      psd_assert(length == 0);      key = psd_stream_get_int(context);      // ornt style      psd_assert(key == 'Ornt');      data->oristyle=psd_stream_get_type_tool_object_orientation_style(context);                                   break;     case 'AntA':                  psd_assert(type=='enum');      // TypeID: 4 bytes (length), followed either by string or (if length is zero) 4-      // byte typeID      length = psd_stream_get_int(context);      psd_assert(length == 0);      key = psd_stream_get_int(context);      // anti style      psd_assert(key == 'Annt');      data->antistyle =psd_stream_get_type_tool_object_antialiasing_style(context);      break; //     case 'warp': //      psd_assert(type=='Objc'); //                  //coutConsole1("warp"); //      break; //     default:        psd_assert(0);       psd_stream_get_object_null(type, context);      break;    } }

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

你可能感兴趣的文章
hdu折线分割平面 递推
查看>>
学习该有的思维方式
查看>>
RColorBrewer的使用
查看>>
http协议基础(一)
查看>>
好看的电影-电视剧
查看>>
Linux:查看磁盘空间占用情况
查看>>
redis发布订阅
查看>>
dubbo+zookeeper
查看>>
ZOJ 3642 Just Another Information Sharing Problem【二分图多重匹配】
查看>>
Ansible基础
查看>>
3D打印材料的发展现状(1)
查看>>
API相关基础知识
查看>>
黑马程序员-面向对象-07天-1 (抽象类描述)
查看>>
1106JS循环
查看>>
FreeBSD从零开始---安装后配置(一)
查看>>
PHP Ajax 跨域问题最佳解决方案
查看>>
Linux之开源软件移植
查看>>
C#.NET SQLite自适应32位/64位系统
查看>>
stl本子
查看>>
浅谈大型网站动态应用系统架构(转)
查看>>