⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jbig.doc

📁 linux下将各类格式图片转换工具
💻 DOC
📖 第 1 页 / 共 3 页
字号:
                 line alternative is selected. God bless the committees.                 Although probably nobody will ever need this option,                 it has been implemented in JBIG-KIT and is off by                 default.  JBG_TPDON      This activates the "typical prediction" algorithm                 for differential layers which avoids that large                 areas of equal color have to be encoded at all.                 This is on by default and there is no good reason to                 switch it off except for debugging or preparing data                 for cheap JBIG hardware which does not support this                 option.  JBG_TPBON      Like JBG_TPDON this activates the "typical prediction"                 algorithm in the lowest resolution layer. Also activated                 by default.  JBG_DPON       This bit activates for the differential resolution                 layers the "deterministic prediction" algorithm,                 which avoids that higher resolution layer pixels are                 encoded when their value can already be determined                 with the knowledge of the neighbor pixels, the                 corresponding lower resolution pixels and the                 resolution reduction algorithm. This is also                 activated by default and one only might perhaps want                 to deactivate it if the default resolution reduction                 algorithm is replaced by a new one.  JBG_DELAY_AT   Use a slightly less efficient algorithm to determine                 when an adaptive template change is necessary. With                 this bit set, the encoder output is compatible to the                 conformance test examples in cause 7.2 of ITU-T T.82.                 Then all adaptive template changes are delayed until                 the first line of the next stripe. This option is by                 default deactivated and only required for passing a                 special compatibility test suite.In addition, parameter l0 in jbg_enc_options() allows you to specifythe number of lines per stripe in resolution layer 0. The parametersmx and my change the maximal offset allowed for the adaptive templatepixel. The JBIG-KIT implementation allows currently a maximal mx valueof 23 in the encoder and 32 in the decoder. Parameter my is at themoment ignored and always set to 0. As the standard requires of alldecoder implementations only a maximum supported mx = 16 and my = 0,higher values should normally be avoided in order to guaranteeinteroperability. Default is mx = 8 and my = 0. If any of theparameters order, options, l0, mx or my is negative, then this valueis ignored and the current value stays unmodified.The resolution reduction and deterministic prediction tables can alsobe replaced. However as these options are anyway only for experts,please have a look at the source code of jbg_enc_out() and the structmembers dppriv and res_tab of struct jbg_enc_state for the details ofhow to do this in case you really need it. The functionsjbg_int2dppriv and jbg_dppriv2int are provided in order to convert theDPTABLE data from the format used in the standard into the moreefficient format used internally by JBIG-KIT.If you want to encode a greyscale image, you can use the libraryfunction  void jbg_split_planes(unsigned long x, unsigned long y, int has_planes,                        int encode_planes,                        const unsigned char *src, unsigned char **dest,                        int use_graycode);It separates an image in which each pixel is represented by one ormore bytes into separate bitplanes. The dest array of pointers tothese bitplanes can then be handed over to jbg_enc_init(). Thevariables x and y specify the width and height of the image in pixels,and has_planes specifies how many bits per pixel are used. As eachpixel is represented by an integral number of consecutive bytes, ofwhich each contains up to eight bits, the total length of the inputimage array src[] will therefore be x * y * ((has_planes + 7) / 8)bytes. The pixels are stored as usually in English reading order, andfor each pixel the integer value is stored with the most significantbyte coming first (Bigendian). This is exactly the format used in rawPGM files. In encode_planes, the number of bitplanes that shall beextracted can be specified. This allows for instance to extract onlythe most significant 8 bits of a 12-bit image, where each pixel isrepresented by two bytes, by specifying has_planes = 12 andencode_planes = 8. If use_graycode is zero, then the binary code ofthe pixel integer values will be used instead of the Gray code. Plane0 contains always the most significant bit.3  Decompressing an imageLike with the compression functions, if you want to use the JBIG-KITlibrary, you have to put the line  #include "jbig.h"into your source code and link your executable with libjbig.a.The state of a JBIG decoder is stored completely in a struct and youwill have to define a variable like  struct jbg_dec_state sd;which is initialized by a call to  void jbg_dec_init(struct jbg_dec_state *s);After this, you can directly start to pass data from the BIE to the decoderby calling the function  int jbg_dec_in(struct jbg_dec_state *s, unsigned char *data, size_t len,                 size_t *cnt);The pointer data points to the first byte of a data block with lengthlen, which contains bytes from a BIE. It is not necessary to pass awhole BIE at once to jbg_dec_in(), it can arrive fragmented in any wayby calling jbg_dec_in() several times. It is also possible to sendseveral BIEs concatenated to jbg_dec_in(), however these then have tofit together. If you send several BIEs to the decoder, the lowestresolution layer in each following BIE has to be the highestresolution layer in the previous BIE plus one and the image sizes andnumber of planes also have to fit together, otherwise jbg_dec_in()will return the error JBG_ENOCONT after the header of the new BIE hasbeen received completely.If pointer cnt is not NULL, then the number of bytes actually readfrom the data block is stored there. In case the data block did notcontain the end of the BIE, then the value JBG_EAGAIN will be returnedand *cnt equals len.Once the end of a BIE has been reached, the return value ofjbg_dec_in() will be JBG_EOK. After this has happened, the functionsand macros  long jbg_dec_getwidth(struct jbg_dec_state *s);  long jbg_dec_getheight(struct jbg_dec_state *s);  int jbg_dec_getplanes(struct jbg_dec_state *s);  unsigned char *jbg_dec_getimage(struct jbg_dec_state *s, int plane);  long jbg_dec_getsize(struct jbg_dec_state *s);can be used to query the dimensions of the now completely decodedimage and to get a pointer to all bitmap planes. The bitmaps arestored as described in section 2.1. The function jbg_dec_getsize()calculates the number of bytes which one bitmap requires.The function  void jbg_dec_merge_planes(const struct jbg_dec_state *s, int use_graycode,                            void (*data_out)(unsigned char *start, size_t len,                                             void *file), void *file);allows you to merge the bitplanes that can be accessed individuallywith jbg_dec_getimage() into an array with one or more bytes per pixel(i.e., the format provided to jbg_split_planes()). If use_graycode iszero, then a binary encoding will be used. The output array will bedelivered via the callback function data_out, exactly in the same wayin which the encoder provides the BIE. The function  long jbg_dec_getsize_merged(const struct jbg_dec_state *s);determines how long the data array delivered by jbg_dec_merge_planes()is going to be.Before calling jbg_dec_in() the first time, it is possible to specify witha call to  void jbg_dec_maxsize(struct jbg_dec_state *s, unsigned long xmax,                       unsigned long ymax);an abort criterion for progressively encoded images. For instance if anapplication will display a whole document on a screen which is 1024 x768 pixels large, then this application should call  jbg_dec_maxsize(&sd, 1024, 768);before the decoding process starts. If the image has been encoded inprogressive mode (i.e. with several resolution layers), then thedecoder will stop with a return value JBG_EOK_INTR after the largestresolution layer that is still smaller than 1024 x 768. However thisis no guarantee that the image which can then be read out usingjbg_dec_getimage(), etc. is really not larger than the specifiedmaximal size. The application will have to check the size of theimage, because the decoder does not automatically apply a resolutionreduction if no suitable resolution layer is available in the BIE.If jbg_dec_in() returned JBG_EOK_INTR or JBG_EOK, then it is possibleto continue calling jbg_dec_in() with the remaining data in order toeither decode the remaining resolution layers of the current BIE or inorder to add another BIE with additional resolution layers. In bothcases, after jbg_dec_in() returned JBG_EOK_INTR or JBG_EOK, *cnt isprobably not equal to len and the remainder of the data block whichhas not yet been processed by the decoder has to be delivered tojbg_dec_in() again.If any other return value than JBG_EOK, JBG_EOK_INTR or JBG_EAGAINhas been returned by jbg_dec_in(), then an error has occurred and  void jbg_dec_free(struct jbg_dec_state *s);should be called in order to release any allocated memory. Thedestructor jbg_dec_free() should of course also be called, once thedecoded bitmap returned by jbg_dec_getimage() is no longer requiredand the memory can be released.The function  const char *jbg_strerror(int errnum, int language);returns a pointer to a short single line test message which explainsthe return value of jbg_dec_in(). This message can be used in order toprovide the user a brief informative message about what when wrongwhile decompressing the JBIG image. The error messages are availablein several languages and in several character sets. Currentlysupported are the following values for the language parameter:  JBG_EN              English messages in ASCII  JBG_DE_8859_1       German messages in ISO 8859-1 Latin 1 character set  JBG_DE_UTF_8        German messages in ISO 10646/Unicode UTF-8 encodingThe current implementation of the JBIG-KIT decoder has the followinglimitations:  - The maximal horizontal offset mx of the adaptive template pixel    must not be larger than 32 and the maximal vertical offset must    be zero.  - HITOLO and SEQ bits must not be set in the order value.A more detailed description of the JBIG-KIT implementation is  Markus Kuhn: Effiziente Kompression von bi-level Bilddaten durch  kontextsensitive arithmetische Codierung. Studienarbeit, Lehrstuhl  f黵 Betriebssysteme, IMMD IV, Universit鋞 Erlangen-N黵nberg,  Erlangen, July 1995. (German, 62 pages)  <http://www.cl.cam.ac.uk/~mgk25/kuhn-sta.pdf>Please quote the above if you use JBIG-KIT in your research project.*** Happy compressing ***[end]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -