int BookEngineInterface.BEIRenderPage(IntPtr handle, int page, IntPtr texture) { int result = 0; switch (format) { case BookFormat.coolreader: result = cri.BEIRenderPage(handle, page, texture); break; case BookFormat.poppler: result = pop.BEIRenderPage(handle, page, texture); break; } return(result); }
// Render and copy a given page to the specified texture. public void retrievePageToTexture(int page, Texture2D texture) { bookEngine.BEIGoToPage(bookHandle, page); bookEngine.BEIRenderPage(bookHandle, page, directRenderTexture.GetNativeTexturePtr()); // Create a mip-mapped texture version. This is extra work but produces much more readable texture. RenderTexture texcopy = RenderTexture.GetTemporary(directRenderTexture.width, directRenderTexture.height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Linear); Graphics.Blit(directRenderTexture, texcopy); RenderTexture previous = RenderTexture.active; RenderTexture.active = texcopy; texture.ReadPixels(new Rect(0, 0, directRenderTexture.width, directRenderTexture.height), 0, 0); texture.Apply(); RenderTexture.active = previous; RenderTexture.ReleaseTemporary(texcopy); }