http://www.contextfree.net/wangyg/i_04.html

來源:互聯網
上載者:User

 

http://www.blog.edu.cn/uploadfile/20041126154711934.RAR

 

http://www.blog.edu.cn/uploadfile/20041126154711934.RARhttp://www.blog.edu.cn/uploadfile/20041126154711934.RARhttp://www.blog.edu.cn/uploadfile/20041126154711934.RAR在遠程渲染系統中伺服器端必須將渲染得到的映像壓縮為JPEG後傳輸。我前天在網上找到了IGP的jpeg庫代碼,但是在VC下編譯總是出錯。這個問題困擾了我整整兩天,今天終於找到了正確的編譯方法。現在總結如下:

第一步:修改一些IGC源檔案(來自http://www.bcbdev.com/articles/jpeg.htm):
/******************* Changes to jpeglib.h **************************/#ifndef JPEGLIB_H#define JPEGLIB_H/* HJH modification: added extern "C" { when __cplusplus detected */#ifdef __cplusplusextern "C" {#endif.../* near bottom of the file *//* HJH modification: add closing } for extern "C" {  */#ifdef __cplusplus}#endif#endif /* JPEGLIB_H *//******************* Changes to jmorecfg.h **************************//* jmorecfg.h line 160 *//* X11/xmd.h correctly defines INT32 *//* HJH modification: jmorecfg.h already contained a test for XMD_H and xmd.h   My change adds a test for _BASETSD_H_ because the windows header file   basestd.h already defines INT32 */#if !defined(XMD_H) && !defined(_BASETSD_H_)typedef long INT32;#endif/* jmorecfg.h line 220 *//* HJH modification: several of the windows header files already define FAR   because of this, the code below was changed so that it only tinkers with   the FAR define if FAR is still undefined */#ifndef FAR  #ifdef NEED_FAR_POINTERS  #define FAR  far  #else  #define FAR  #endif#endif
最後需要修改jconfig.h檔案
/* HJH Note: Here is one key addition that I had to make. The jpeg library uses #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ typedef unsigned char boolean; #endif #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
* a type called boolean. It defines boolean here. However, RPCNDR.H * yet another Microsoft header, also defines boolean. The ifndef * ensures that we don't attempt to redefine boolean if rpcndr.h has * already defined it. Note that we use unsigned char instead of int * like jmorecfg.h does, because we want to match what's in the SDK * header. See jconfig.vc for more info, it does the same thing. */第二步:編譯(來自IGP解壓後的檔案夾中的install.doc):
1. Copy jconfig.vc to jconfig.h, makelib.ds to jpeg.mak, and
   makeapps.ds to apps.mak. (Note that the renaming is critical!)
2. Click on the .mak files to construct project workspaces.
   (If you are using DevStudio more recent than 4.2, you'll probably
   get a message saying that the makefiles are being updated.)
3. Build the library project, then the applications project.
4. Move the application .exe files from `app`/Release to an
   appropriate location on your path.
5. To perform the self-test, execute the command line
    NMAKE /f makefile.vc test
實際上只需要執行前三步就可以。在release檔案夾中可以得到最後編譯的結果jpeg.lib庫檔案。第三步:在自己的代碼中包含
#pragma comment(lib, "jpeg.lib")

#i nclude "jpeglib.h"Done!

 

 

使用ijg 解碼到緩衝區[原創]今天開發一個程式需要使用IJG的庫,這個庫倒是用了很多年了,關於編碼的處理範例中使用的是輸出到檔案流   查看文檔 發現這個章節:Compressed data handling (source and destination managers)裡面有實現的描述The JPEG compression library sends its compressed data to a "destination
manager" module.  The default destination manager just writes the data to a
stdio stream, but you can provide your own manager to do something else.
Similarly, the decompression library calls a "source manager" to obtain the
compressed data; you can provide your own source manager if you want the data
to come from somewhere other than a stdio stream. OK!看來問題便簡單了主要步驟:init_destination (j_compress_ptr cinfo)
 Initialize destination.  This is called by jpeg_start_compress()
 before any data is actually written.  It must initialize
 next_output_byte and free_in_buffer.  free_in_buffer must be
 initialized to a positive value.empty_output_buffer (j_compress_ptr cinfo)
 This is called whenever the buffer has filled (free_in_buffer
 reaches zero).  In typical applications, it should write out the
 *entire* buffer (use the saved start address and buffer length;
 ignore the current state of next_output_byte and free_in_buffer).
 Then reset the pointer & count to the start of the buffer, and
 return TRUE indicating that the buffer has been dumped.
 free_in_buffer must be set to a positive value when TRUE is
 returned.  A FALSE return should only be used when I/O suspension is
 desired (this operating mode is discussed in the next section).term_destination (j_compress_ptr cinfo)
 Terminate destination --- called by jpeg_finish_compress() after all
 data has been written.  In most applications, this must flush any
 data remaining in the buffer.  Use either next_output_byte or
 free_in_buffer to determine how much data is in the buffer.


王老師:    您好!    我想可能我的學習方法有問題。我已經看了將近一個月的ijg庫的jpeg解碼程式,可是到現在我還是沒有真正理解,對怎樣用到自己的嵌入式開發中還是覺得無處下手。    djpeg.c可以將jpeg檔案轉換成bmp檔案,但是我們的系統並不能識別bmp圖,只能轉換成原始的資料流。我現在很迷茫,您能不能指點一下,我該補充哪些方面的知識,希望您能就自己的經驗建議一種好的學習方法,讓我少走一些彎路。    另外有一些概念需要您給解釋一下:upsampling和dithering.one-pass color quantization和 two-pass color quantization.        十分感謝!!            
2004-12-03 12:14 回複
djpeg.c只是對ijg庫的封裝(封裝成一個可執行檔命令列程式),對bmp映像的處理等都是外圍封裝部分。你如果想得到原始的資料流,只要使用ijg庫本身的介面來開發就可以了,沒有必要關心djpeg程式。ijg庫本身的使用方法在jconfig.doc中有詳細說明,example.c、djpeg.c等程式中又有範例程式碼,具體的介面在jpeglib.h中都可以查到。如果僅是使用ijg庫的話,似乎沒有你說的那麼難。從你以前的來信中,我的感覺是,你的C語言功力還需要提高,否則可能駕馭不了ijg這樣比較複雜的C語言函數庫。此外,如果你想深入到JPEG演算法內部(比如,你說的upsampling、quantization等都是JPEG演算法中的常用術語),你可能還需要再熟悉一些JPEG演算法的細節,比如參考一下相關的圖書和資料。祝你成功!

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.