- Posts: 36
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Android development and PDF
Cache for PDFViewThumb
- thiagopelikan
- Topic Author
- Offline
- User is blocked
-
Less
More
IP: 177.55.163.6
7 years 4 weeks ago #14625
by thiagopelikan
Replied by thiagopelikan on topic Cache for PDFViewThumb
I'm trying to implement above as you mentioned but I'm having problems to do this.
I think the structure is ok but I didn't understood how to use BMP and DIB objects, could you please help me on that?
For now, I have:
The files are saved correctly but loading it and render the page from the file is not working.
Tks,
Thiago
I think the structure is ok but I didn't understood how to use BMP and DIB objects, could you please help me on that?
For now, I have:
Code:
protected void RenderThumb() {
Bitmap bitmap = null;
if (m_status == 2) return;
if (m_page == null)
m_page = m_doc.GetPage(m_pageno);
File thumbPath = getThumbPath(m_pageno);
if (thumbPath.exists()) {
bitmap = CommonUtil.loadThumb(thumbPath);
BMP bmp = new BMP();
bmp.Create(bitmap);
m_dib = new DIB();
bmp.DrawToDIB(m_dib, m_dibw, m_dibh);
Matrix mat = new Matrix(m_scale, -m_scale, 0, m_dibh);
//How to get a Bitmap object and add to DIB Object
//How to render a page using a DIB OBJECT
m_page.RenderPrepare(m_dib);
m_page.Render(m_dib, mat);
mat.Destroy();
} else {
if (m_dib == null) {
DIB dib = new DIB();
dib.CreateOrResize(m_dibw, m_dibh);
m_page.RenderPrepare(dib);
m_dib = dib;
} else m_page.RenderPrepare(m_dib);
if (m_status == 2) return;
if (!m_page.RenderThumbToDIB(m_dib)) {
Matrix mat = new Matrix(m_scale, -m_scale, 0, m_dibh);
m_page.Render(m_dib, mat);
bitmap = Bitmap.createBitmap(m_dibw, m_dibh, Bitmap.Config.ARGB_8888);
//IS IT NECESSARY TO RENDER AS THUMB HERE?? I Tried m_dib.ToBMP without success
m_page.RenderThumb(bitmap);
CommonUtil.saveThumb(bitmap, thumbPath);
mat.Destroy();
}
}
if (m_status != 2)
m_status = 1;
}
The files are saved correctly but loading it and render the page from the file is not working.
Tks,
Thiago
IP: 111.196.241.37
7 years 4 weeks ago - 7 years 4 weeks ago #14626
by radaee
change to:
Replied by radaee on topic Cache for PDFViewThumb
Code:
bitmap = CommonUtil.loadThumb(thumbPath);
BMP bmp = new BMP();
bmp.Create(bitmap);
m_dib = new DIB();
bmp.DrawToDIB(m_dib, m_dibw, m_dibh);
Matrix mat = new Matrix(m_scale, -m_scale, 0, m_dibh);
//How to get a Bitmap object and add to DIB Object
//How to render a page using a DIB OBJECT
m_page.RenderPrepare(m_dib);
m_page.Render(m_dib, mat);
mat.Destroy();
Code:
m_dib = new DIB();
m_dib.CreateOrResize(m_dibw, m_dibh);
Matrix mat = new Matrix(m_scale, -m_scale, 0, m_dibh);
m_page.RenderPrepare(m_dib);
m_page.Render(m_dib, mat);
mat.Destroy();
bitmap = Bitmap.CreateBitmap(m_dibw, m_dibh, ARGB_8888);
BMP bmp = new BMP();
bmp.Create(bitmap);
m_dib.DrawToBMP(bitmap, m_dibw, m_dibh);
bmp.Free(bitmap);
bitmap.Compress(...);
Last edit: 7 years 4 weeks ago by radaee.
- thiagopelikan
- Topic Author
- Offline
- User is blocked
-
Less
More
- Posts: 36
- Thank you received: 0
IP: 200.236.249.149
7 years 4 weeks ago #14627
by thiagopelikan
Replied by thiagopelikan on topic Cache for PDFViewThumb
The lines you ask me to change are responsible for loading bitmap from sdcard. Using your lines I'll never read files, isn't that correct?
IP: 111.196.241.37
7 years 4 weeks ago - 7 years 4 weeks ago #14628
by radaee
Replied by radaee on topic Cache for PDFViewThumb
sorry, not see your codes in correct way.
Code:
if (thumbPath.exists()) {//if load from storage
bitmap = CommonUtil.loadThumb(thumbPath);
BMP bmp = new BMP();
bmp.Create(bitmap);
m_dib = new DIB();
m_dib.CreateOrResize(m_dibw, m_dibh);
bmp.DrawToDIB(m_dib, 0, 0);
bmp.Free(bitmap);
} else {//if not load from storage, we render to DIB, then draw to BMP
if( m_dib == null )
{
DIB dib = new DIB();
dib.CreateOrResize( m_dibw, m_dibh );
m_page.RenderPrepare(dib);
m_dib = dib;
}
else m_page.RenderPrepare(m_dib);
if( m_status == 2 ) return;
if(!m_page.RenderThumbToDIB(m_dib))
{
Matrix mat = new Matrix(m_scale, -m_scale, 0, m_dibh);
m_page.Render(m_dib, mat);
mat.Destroy();
}
bitmap = Bitmap.createBitmap(m_dibw, m_dibh, Bitmap.Config.ARGB_8888);
BMP bmp = new BMP();
bmp.Create(bitmap);
m_dib.DrawToBMP(bmp, 0, 0);
bmp.Free(bitmap);
CommonUtil.saveThumb(bitmap, thumbPath);
}
if (m_status != 2)
m_status = 1;
}
Last edit: 7 years 4 weeks ago by radaee.
Time to create page: 0.329 seconds