rotate

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
guest
Posts: 268
Joined: Mon 02 Apr 2018, 09:12

Re: rotate

Post by guest » Wed 31 Oct 2018, 14:21

TOLO wrote:
Wed 31 Oct 2018, 13:04
I have some problems with PlgBlt … What I need is to rotate a BMP 1280 x 1024 bit for 90 deg contra clockwise.
Rotating by a right-angle is a simple case. The docs for PlgBlt state of the supplied array of points: "The upper-left corner of the source rectangle is mapped to the first point in this array, the upper-right corner to the second point in this array, and the lower-left corner to the third point". Assuming the source and rotated bitmaps are located at (0,0) the code therefore needs to be (untested):

Code: Select all

      DIM pt{x% ,y%}, pt{(2)} = pt{}
      pt{(0)}.x% = 0    : pt{(0)}.y% = 1280
      pt{(1)}.x% = 0    : pt{(1)}.y% = 0
      pt{(2)}.x% = 1024 : pt{(2)}.y% = 1280
      SYS "PlgBlt", hdcDest%, pt{(0)}, hdcSrc%, 0, 0, 1280, 1024, 0, 0, 0
You may well need to prefix this with a SYS "SetStretchBltMode" … to improve the quality.

TOLO
Posts: 3
Joined: Wed 31 Oct 2018, 10:02

Re: rotate

Post by TOLO » Wed 31 Oct 2018, 20:44

Thank you very much for fast response...

Now I can not figure out how to write down hdcDest% and hdcSrc%. I can display my bmp on the monitor or I can tell where it is in the folder and this I suppose should be told in hdcSrc......


Regards

Lojze

guest
Posts: 268
Joined: Mon 02 Apr 2018, 09:12

Re: rotate

Post by guest » Wed 31 Oct 2018, 22:56

TOLO wrote:
Wed 31 Oct 2018, 20:44
Now I can not figure out how to write down hdcDest% and hdcSrc%. I can display my bmp on the monitor...
If the source bitmap is displayed in BBC BASIC's window, and you are happy for the rotated bitmap to be put there too, then simply set both source and destination DC to @memhdc%. Alternatively you can create a new DC and bitmap for the source and/or destination in your program (suitable code can be found at the wiki, for example here).

If you use BB4W's window for the source and destination bitmaps, which is the simplest solution, remember that the origin (0,0) is at the top left as far as PlgBlt is concerned and at the bottom left as far as BBC BASIC's graphics coordinates are concerned. Some care may be necessary in determining the parameters for the *DISPLAY and *GSAVE commands.

TOLO
Posts: 3
Joined: Wed 31 Oct 2018, 10:02

Re: rotate

Post by TOLO » Wed 31 Oct 2018, 23:04

thank you

Post Reply