summaryrefslogtreecommitdiff
path: root/atari/bitmap.c
diff options
context:
space:
mode:
authorOle Loots <ole@monochrom.net>2012-07-23 02:03:09 +0200
committerOle Loots <ole@monochrom.net>2012-07-23 02:03:09 +0200
commit2158ed7bce81e884effecf747ee8430042c08056 (patch)
treed4e8bdb989357a86aa6f9a9b9c79a35b8a5579dd /atari/bitmap.c
parent5433eecfeaf0517a3ed91b2a2beb9f78eaf4cef6 (diff)
downloadnetsurf-2158ed7bce81e884effecf747ee8430042c08056.tar.gz
netsurf-2158ed7bce81e884effecf747ee8430042c08056.tar.bz2
moved "bitmap_resize()" to bitmap.c
Diffstat (limited to 'atari/bitmap.c')
-rwxr-xr-xatari/bitmap.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/atari/bitmap.c b/atari/bitmap.c
index 9cfebcaf6..1201ac88a 100755
--- a/atari/bitmap.c
+++ b/atari/bitmap.c
@@ -429,6 +429,61 @@ size_t bitmap_get_bpp(void *bitmap)
return bm->bpp;
}
+bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
+ HermesFormat *fmt, int nw, int nh)
+{
+ short bpp = bitmap_get_bpp( img );
+ int stride = bitmap_get_rowstride( img );
+ int err;
+
+ if( img->resized != NULL ) {
+ if( img->resized->width != nw || img->resized->height != nh ) {
+ bitmap_destroy( img->resized );
+ img->resized = NULL;
+ } else {
+ /* the bitmap is already resized */
+ return(true);
+ }
+ }
+
+ /* allocate the mem for resized bitmap */
+ img->resized = bitmap_create_ex( nw, nh, bpp, nw*bpp, 0, NULL );
+ if( img->resized == NULL ) {
+ printf("W: %d, H: %d, bpp: %d\n", nw, nh, bpp);
+ assert(img->resized);
+ return(false);
+ }
+
+ /* allocate an converter, only for resizing */
+ err = Hermes_ConverterRequest( hermes_h,
+ fmt,
+ fmt
+ );
+ if( err == 0 ) {
+ return(false);
+ }
+
+ err = Hermes_ConverterCopy( hermes_h,
+ img->pixdata,
+ 0, /* x src coord of top left in pixel coords */
+ 0, /* y src coord of top left in pixel coords */
+ bitmap_get_width( img ), bitmap_get_height( img ),
+ stride, /* stride as bytes */
+ img->resized->pixdata,
+ 0, /* x dst coord of top left in pixel coords */
+ 0, /* y dst coord of top left in pixel coords */
+ nw, nh,
+ bitmap_get_rowstride(img->resized) /* stride as bytes */
+ );
+ if( err == 0 ) {
+ bitmap_destroy( img->resized );
+ img->resized = NULL;
+ return(false);
+ }
+
+ return(true);
+}
+
/*
* Local Variables:
* c-basic-offset:8