Rotate and Flip images with GdiPlusX

some people have been asking about rotating / flipping images with gdiplusx.

here's some adapted code from a previous post that used _gdiplus.vcx, but this time using gdiplusx:


rotating and / or flipping images is a very simple task for gdi+. to see the different results possible, change the constant value in the variable lnenumrotateflip in the code below.


requires vfp9 and gdiplusx to run. 
please make sure that you have the latest version!


* init gdiplusx
do locfile("system.app")

local lobmp as xfcbitmap
local lnenumrotateflip

with _screen.system.drawing

   lobmp = .bitmap.fromfile(getpict())
   lnenumrotateflip = .rotatefliptype.rotate90flipnone  && try changing this value for the presented below

   * to save the image as png
   lobmp.save("c:\rotateflip.png", .imaging.imageformat.png)

run /n explorer.exe rotateflip.png



rotatenoneflipnone 0 

rotate90flipnone   1 

rotate180flipnone  2 

rotate270flipnone  3 

rotatenoneflipx    4 

rotate90flipx      5 

rotate180flipx     6 

rotate270flipx     7 


  1. Very cool - but would you really want a LOCFILE() in this?  I would just pop an error message and return .f. it it couldn't find System.VCX
    Hi Ken,
    Thanks for your comment.
    We`re using LOCFILE() in almost every sample to ease the task for users to run the codes. We hope GdiPlusX will help beginners and experts.
    Using LOCFILE() in the samples, users wont need to worry to SET PATH or to throw the samples in the "source" folder.
    Of course, if the user will use those samples in a project, the GdiPlusX library will need to be added to the project, and LOCFILE() will be removed. Was I clear ?

  2. Hi Cesar.

    Then, if I want to put GdiPlusX in a real project I need to put the library in my "Clases" directory and have a reference in the path's for GdiPlusX, really?.

    Greath work Cesar.

    PS: Sorry for the bad english
    Hi, Just add the library to your project, and that's all. Don't forget to clear the "LOCFILE()" command in the initialization of GDI+. Once it's in the project, your EXE will find it automatically.
    Good luck !

  3. Hi Cesar. Grettings from the hot Asunción of Paraguay. Thanks for your excelent work.
    I just wanna to know how i can make a blur effects in a image with GDI+. I do this with a DLL (gdpicture), but it is not free, but it's possible. Please replay me. Thanks
    Here you are !
    Blur Images with GdiPlusX

  4. lnEnumRotateFlip = .RotateFlipType.Rotate90FlipNone

    isnt exactly nice esp. if you want to got a Button to Rotate 90° Right + Flip so here is how you do that:

    lnFlip = MOD(thisform.RotateRight + thisform.RotateX*4 + thisform.RotateY*6,8)


    - this is if you ALWAYS use a original Image and NOT Rotate the oBMP twice++

    - so if you do that without using a org. Clone  clicking "RotateRight" twice will actually get you 270° instead of 180°

    there the Commands

    CMD Rotate 90° Right -> Click() = thisform.RotateRight=MOD(thisform.RotateRight+1,4)

    CMD Rotate 90° Left -> Click() = thisform.RotateRight=MOD(thisform.RotateRight-1,4)

    CMD Flip Y -> Click()  = thisform.rotateY = MOD(thisform.RotateY + 1,2)

    CMD Flip X -> Click()  = thisform.rotateX = MOD(thisform.RotateX + 1,2)

    so it doesnt matter which CMD you click in which order it roates the right angle if

  5. Versión en Español de este artículo en / Spanish version at http://www.portalfox.com/article.php?sid=2454  

  6. Hi Cesar.
    Can we use system.app to rotate images by any desired angle ? Thank you very much
    Hi Warren,
    Sure you can ! Please refer to the samples provided with GdiPlusX, there are a couple showing you how to do this :-D