The MASM Forum

General => The Laboratory => Topic started by: guga on November 10, 2020, 06:20:09 PM

Title: Affine transformation
Post by: guga on November 10, 2020, 06:20:09 PM
Hi Guys

Someone already tried to do some Affine transformations with GDIPlus directly from the pixel data of a image ?


I´m reading some examples here

https://www.codeproject.com/Tips/516761/Affine-Transformations-in-Computer-Graphics
https://github.com/LidaPetr/affine-transformation/blob/master/aurora.cpp
https://engineerslaboratory.wordpress.com/2016/08/27/affine-transformation-in-image-processing-explained-with-c/
https://en.wikipedia.org/wiki/Affine_transformation

Maybe could be a good idea to give a try. I wonder if using gdi plus to retrieve the pixel data and manipulating it directly to perform those tranformations could be faster the using the gdi+ apis itself. ?
Title: Re: Affine transformation
Post by: TouEnMasm on November 10, 2020, 08:16:57 PM

Try to complie the first,little problem "#include <graphics.h>" no more exist.
Seem to be an old sample ,some says it's directx and some says it's opengl ????
Title: Re: Affine transformation
Post by: TimoVJL on November 10, 2020, 08:45:51 PM
https://sourceforge.net/projects/openbgi/

https://github.com/nirin/WinBGI
Title: Re: Affine transformation
Post by: TouEnMasm on November 11, 2020, 01:32:06 AM

Thanks for links
https://github.com/nirin/WinBGI (https://github.com/nirin/WinBGI)     ;works (without errors !!!) with win10 VS2019 C++

Title: Re: Affine transformation
Post by: TouEnMasm on November 11, 2020, 03:11:27 AM
First sample compiled ,works 64 in dos or Windows mode.Stop with spacebar.
Library too big for the forum.
can surely be done more easily with opengl. http://masm32.com/board/index.php?topic=8885.msg97287#msg97287 (http://masm32.com/board/index.php?topic=8885.msg97287#msg97287)

second sample
Quote
Microsoft Windows [version 10.0.19042.572]
(c) 2020 Microsoft Corporation. Tous droits réservés.

H:\ecrase>math
Affine Transformation is being created
Affine Transformation is being created
Affine Transformation is being created
Initial values:
1 0
Transformation:
3 -3
Inverse Transformation:
1 -2.22045e-16
Combined Transformation:
1 0

H:\ecrase>
Title: Re: Affine transformation
Post by: TimoVJL on November 11, 2020, 03:34:29 AM
With these dll's it worked in Windows 7
Title: Re: Affine transformation
Post by: guga on November 11, 2020, 05:22:11 AM
Quote from: TouEnMasm on November 11, 2020, 03:11:27 AM
First sample compiled ,works 64 in dos or Windows mode.Stop with spacebar.
Library too big for the forum.
can surely be done more easily with opengl. http://masm32.com/board/index.php?topic=8885.msg97287#msg97287 (http://masm32.com/board/index.php?topic=8885.msg97287#msg97287)

second sample
Quote
Microsoft Windows [version 10.0.19042.572]
(c) 2020 Microsoft Corporation. Tous droits réservés.

H:\ecrase>math
Affine Transformation is being created
Affine Transformation is being created
Affine Transformation is being created
Initial values:
1 0
Transformation:
3 -3
Inverse Transformation:
1 -2.22045e-16
Combined Transformation:
1 0

H:\ecrase>

:dazzled: :dazzled: :dazzled: :dazzled:

How did you managed to compiled ? Can it be one in VisualStudio and for x86 ?

Title: Re: Affine transformation
Post by: avcaballero on November 11, 2020, 08:36:15 AM
Well, this is an example on GDI, rotating and scaling, if you are interested in source code:
http://abreojosensamblador.epizy.com/?Tarea=5&SubTarea=6#Rotozoomer

Using matrices to achieve such transformations is easy, I could make an example when have time

Here an example using a bitmap, it can accept any bmp file (drag and drop)
http://masm32.com/board/index.php?topic=7145.msg88350#msg88350
Title: Re: Affine transformation
Post by: TouEnMasm on November 11, 2020, 07:22:13 PM
Quote
How did you managed to compiled ? Can it be one in VisualStudio and for x86 ?
On windows 10 with c++ of visual studio 2019,64 bits
* First step download the c++ project for the winbgi library (upper post,master....)
   del the soluce,open the project,compile with visual studio,He is very easy to compile in 32 or 64(no one error).
   When it is done,dowload the source code i have posted,made it compilable,it is compiled with command line,not visual studio.
* Now you have just to delet the code (except  include and lib),replace the code by the second sample,It much work at the first time.

You can made a batch with that

EditMasmIni
Pour les variables d'environnements:
-* l'ancienne variable,si elle existe,est remplacé entièrement
-* chaque chemin s'ajoute,le ; est ajouté
Par défaut,le mot suivant EditMasmIni (en début de ligne) est considéré comme une variable
d'environnement,à moins qu'il ne fasse partie de la liste de mots réservés


EditMasmIni RESERVELISTE
;rien pour l'instant , éventuel futur


EditMasmIni Platform
X64

EditMasmIni PATH
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx64\x64
C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64

EditMasmIni LIB
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\lib\x64

EditMasmIni INCLUDE
C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um
C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared
C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include

EditMasmIni PROCESSEUR
X64

EditMasmIni CL
/c /FA /Gm- /GS- /Ox /MD

EditMasmIni LINK
/NOLOGO

EditMasmIni FindeEditMasmIni

Title: Re: Affine transformation
Post by: guga on November 12, 2020, 06:29:12 AM
Quote from: caballero on November 11, 2020, 08:36:15 AM
Well, this is an example on GDI, rotating and scaling, if you are interested in source code:
http://abreojosensamblador.epizy.com/?Tarea=5&SubTarea=6#Rotozoomer

Using matrices to achieve such transformations is easy, I could make an example when have time

Here an example using a bitmap, it can accept any bmp file (drag and drop)
http://masm32.com/board/index.php?topic=7145.msg88350#msg88350

Tks, Caballero

Please, when you have some time, try making some examples of transformations using matrices (whose pixel where retrieved from bitmap etc )
Title: Re: Affine transformation
Post by: avcaballero on November 16, 2020, 09:21:41 AM
The same using matrices
Title: Re: Affine transformation
Post by: guga on November 20, 2020, 08:06:25 PM
 :dazzled: :dazzled: :dazzled: :dazzled:

Tks a lot, caballero :thumbsup: :thumbsup: :thumbsup:

Great Work :thumbsup: