warren
Junior Member
Posts: 11
|
Post by warren on Mar 12, 2015 22:48:30 GMT -8
|
|
|
Post by jamesbowman on Mar 13, 2015 6:53:40 GMT -8
You can scale, rotate and translate bitmaps using the commands listed on p. 42-45 of the book. These commands are actually just setting the bitmap matrix - this is what controls the bitmap transform. You can directly set this matrix using low-level commands like this: GD.BitmapTransformA(256); GD.BitmapTransformB(0); GD.BitmapTransformC(0); GD.BitmapTransformD(0); GD.BitmapTransformE(256); GD.BitmapTransformF(0);
The six-element matrix works as a transform like this: A B C D E F
and the hardware divides each element by 256, so the above code actually sets the matrix to the identify: 1.0 0 0 0 1.0 0
So to make a matrix to shrink every bitmap by half: GD.BitmapTransformA(512); GD.BitmapTransformB(0); GD.BitmapTransformC(0); GD.BitmapTransformD(0); GD.BitmapTransformE(512); GD.BitmapTransformF(0);
|
|
jk
Junior Member
Posts: 10
|
Post by jk on Mar 13, 2015 11:58:33 GMT -8
I have an question related to this post. I want to zoom a bitmap with x,y pixel to the double size 2x,2y, as shown on page 45. What are the neccesary commands to make the whole bitmap visible? Before doing this I would like to calculate the width and height after loading the jpeg (with getprops command?). Could you help with a code snippet for this.
|
|
|
Post by jamesbowman on Mar 13, 2015 17:58:27 GMT -8
Sure, if you have a bitmap sized (x, y) and want to zoom it to double size, then you do two things: increase its on-screen size, and load a "2x" transform.
To increase its on-screen size:
GD.BitmapSize(NEAREST, BORDER, BORDER, 2 * x, 2 * y);
and to load the "2x" transform:
GD.cmd_scale(F16(2), F16(2)); GD.cmd_setmatrix(); After this, drawing the bitmap will result in the double-sized version.
|
|
|
Post by jamesbowman on Mar 13, 2015 17:58:31 GMT -8
Sure, if you have a bitmap sized (x, y) and want to zoom it to double size, then you do two things: increase its on-screen size, and load a "2x" transform.
To increase its on-screen size:
GD.BitmapSize(NEAREST, BORDER, BORDER, 2 * x, 2 * y);
and to load the "2x" transform:
GD.cmd_scale(F16(2), F16(2)); GD.cmd_setmatrix(); After this, drawing the bitmap will result in the double-sized version.
|
|
|
Post by Ulrich on Feb 27, 2016 0:41:28 GMT -8
In my example this code snippet doesn't work. The bitmap Pixel are Doubled but the viewport is always the the original one so that only the left upper Region of the doubled bitmap is shown.
What's wrong?
|
|
|
Post by Ulrich on Feb 27, 2016 7:23:25 GMT -8
In my example this code snippet doesn't work. The bitmap Pixel are Doubled but the viewport is always the the original one so that only the left upper Region of the doubled bitmap is shown. What's wrong? To be more accurate: when I load more jpegs (with handle numbers 0, 1, 2, ...) only the first one (with handle 0) is displayed correctly. For the bitmaps 1, 2, 3, ... only the left upper quadtrant is shown. Best Regards Ulrich
|
|