Implement thumbnail creation

svn path=/trunk/netsurf/; revision=6736
This commit is contained in:
Chris Young 2009-03-08 17:41:24 +00:00
parent a198acb753
commit 0bdcf4b8e2
3 changed files with 66 additions and 8 deletions

View File

@ -508,8 +508,11 @@ void gui_init2(int argc, char** argv)
}
}
/* init shared bitmaps */
glob.bm = p96AllocBitMap(scrn->Width,scrn->Height,32,
/* init shared bitmaps *
* Height is set to screen width to give enough space for thumbnails *
* Also applies to the further gfx/layers functions and memory below */
glob.bm = p96AllocBitMap(scrn->Width,scrn->Width,32,
BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED,
scrn->RastPort.BitMap,RGBFB_A8R8G8B8);
@ -521,7 +524,7 @@ void gui_init2(int argc, char** argv)
glob.layerinfo = NewLayerInfo();
glob.rp.Layer = CreateUpfrontLayer(glob.layerinfo,glob.bm,0,0,
scrn->Width-1,scrn->Height-1,0,NULL);
scrn->Width-1,scrn->Width-1,0,NULL);
glob.areabuf = AllocVec(100,MEMF_PRIVATE | MEMF_CLEAR);
glob.rp.AreaInfo = AllocVec(sizeof(struct AreaInfo),MEMF_PRIVATE | MEMF_CLEAR);
@ -530,11 +533,11 @@ void gui_init2(int argc, char** argv)
InitArea(glob.rp.AreaInfo,glob.areabuf,100/5);
glob.rp.TmpRas = AllocVec(sizeof(struct TmpRas),MEMF_PRIVATE | MEMF_CLEAR);
glob.tmprasbuf = AllocVec(scrn->Width*scrn->Height,MEMF_PRIVATE | MEMF_CLEAR);
glob.tmprasbuf = AllocVec(scrn->Width*scrn->Width,MEMF_PRIVATE | MEMF_CLEAR);
if((!glob.tmprasbuf) || (!glob.rp.TmpRas)) warn_user("NoMemory","");
InitTmpRas(glob.rp.TmpRas,glob.tmprasbuf,scrn->Width*scrn->Height);
InitTmpRas(glob.rp.TmpRas,glob.tmprasbuf,scrn->Width*scrn->Width);
currp = &glob.rp;
#ifdef NS_AMIGA_CAIRO

View File

@ -103,7 +103,7 @@ void ami_cairo_set_dashed(cairo_t *cr)
bool ami_clg(colour c)
{
p96RectFill(currp,0,0,scrn->Width-1,scrn->Height-1,
p96RectFill(currp,0,0,scrn->Width-1,scrn->Width-1,
p96EncodeColor(RGBFB_A8B8G8R8,c));
/*
SetRPAttrs(currp,RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),

View File

@ -1,5 +1,5 @@
/*
* Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
* Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@ -17,9 +17,64 @@
*/
#include "desktop/browser.h"
#include <proto/graphics.h>
#include <proto/Picasso96API.h>
#include <intuition/intuition.h>
#include <graphics/blitattr.h>
#include <graphics/composite.h>
#include "amiga/gui.h"
#include "amiga/bitmap.h"
bool thumbnail_create(struct content *content, struct bitmap *bitmap,
const char *url)
{
return false;
struct BitScaleArgs bsa;
bitmap->nativebm = p96AllocBitMap(bitmap->width,bitmap->height,32,
BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED,glob.bm,RGBFB_A8R8G8B8);
bitmap->nativebmwidth = bitmap->width;
bitmap->nativebmheight = bitmap->height;
ami_clearclipreg(currp);
content_redraw(content, 0, 0, content->width, content->width,
0, 0, content->width, content->width, 1.0, 0xFFFFFF);
if(GfxBase->lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1)
{
CompositeTags(COMPOSITE_Src,glob.bm,bitmap->nativebm,
COMPTAG_ScaleX,COMP_FLOAT_TO_FIX(bitmap->width/content->width),
COMPTAG_ScaleY,COMP_FLOAT_TO_FIX(bitmap->height/content->width),
COMPTAG_Flags,COMPFLAG_IgnoreDestAlpha | COMPFLAG_SrcAlphaOverride,
COMPTAG_DestX,0,
COMPTAG_DestY,0,
COMPTAG_DestWidth,bitmap->width,
COMPTAG_DestHeight,bitmap->height,
COMPTAG_OffsetX,0,
COMPTAG_OffsetY,0,
TAG_DONE);
}
else
{
bsa.bsa_SrcX = 0;
bsa.bsa_SrcY = 0;
bsa.bsa_SrcWidth = content->width;
bsa.bsa_SrcHeight = content->width;
bsa.bsa_DestX = 0;
bsa.bsa_DestY = 0;
// bsa.bsa_DestWidth = width;
// bsa.bsa_DestHeight = height;
bsa.bsa_XSrcFactor = content->width;
bsa.bsa_XDestFactor = bitmap->width;
bsa.bsa_YSrcFactor = content->width;
bsa.bsa_YDestFactor = bitmap->height;
bsa.bsa_SrcBitMap = glob.bm;
bsa.bsa_DestBitMap = bitmap->nativebm;
bsa.bsa_Flags = 0;
BitMapScale(&bsa);
}
if (url) urldb_set_thumbnail(url, bitmap);
return true;
}