1 / 6

Using Image Encoders and Decoders

Using Image Encoders and Decoders. Introduction. Storing and manipulating Image Image class & Bitmap class Encoder translates the data in an image object into a file Decoder translates the data in a file into an image object. Introduction. GDI+ built-in encoders & decoders

kamala
Download Presentation

Using Image Encoders and Decoders

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Image Encoders and Decoders

  2. Introduction • Storing and manipulating Image • Image class & Bitmap class • Encoder translates the data in an image object into a file • Decoder translates the data in a file into an image object

  3. Introduction • GDI+ built-in encoders & decoders • BMP, GIF, JPEG, PNG, TIFF • WMF, EMF , ICON (Only decoder) • Listing Installed Encoders • You can use GetImageEncoders() to determine which image encoders are available • Return  array of ImageCodecInfo objects • 呼叫前,要先配置足夠大的空間 • GetImageEncodersSize

  4. 列出機器上的 Codec 範例

  5. Retrieving the Class Identifier for an Encoder • 利用 GetEncoderClsid可以得到指定 encoder 的 class identifier (CLSID) • 內建的 MINE type encode 為 • image/bmp ; image/jpeg ;image/gif ; image/png • image/tiff; image/png CLSID encoderClsid; INT result; WCHAR strGuid[39]; result = GetEncoderClsid(L"image/png", &encoderClsid); wprintf(L"The CLSID of the PNG encoder is %s.\n", strGuid); • 傳回 image/png 的 class identifier The CLSID of the PNG encoder is {557CF406-1A04-11D3-9A73-0000F81EF32E}.

  6. 簡單的影像處理 Bitmap * image = new Bitmap (L"rain1.BMP"); // Step 5: 進行影像處理 int Height=image->GetHeight(); int Width=image->GetWidth(); Color c; for(int y=0;y<Height;y++) for(int x=0;x<Width;x++){ image->GetPixel(x,y,&c); int gray=(c.GetR()+c.GetG()+c.GetB())/3; Color g(gray,gray,gray); image->SetPixel(x,y,g); } 使用 Bitmap Object 讀取指定位置上的一點 設定新的值 ImageComponent

More Related