How to write a new image format decoder in Chrome Browser

北城余情 提交于 2019-12-04 19:27:46

Yes, I think the solution you've described will mostly work, though you may need to load the image using an <embed src="..." type="image/jbig2"> instead of <img>.

Basically, you will:

  1. Compile the JBig2 decoder using the Native Client SDK
  2. Add the PPAPI plugin entry point. See any of the examples in the NaCl SDK, or the tutorial here.
  3. In your derived Instance class, implement the virtual function HandleDocumentLoad. This function will be called when your Native Client plugin is used as a mimetype loader. You can use the URLLoader object that is passed to read your JBig2 file.
  4. Create a 2D graphics context, and display the contents of the decoded image in it. Take a look at the Graphics2D example in the NaCl SDK (examples/api/graphics2d).
  5. Make a Chrome extension that registers itself as a JBig2 Native Client mimetype handler (as you've already found).
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!