• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

GDImage 5.00

Started by Patrice Terrier, May 03, 2009, 04:00:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

GDImage 5.00

This is the first project based upon version 5.00, that comes with many advanced (and exclusive) new graphic APIs.

WARNING: If you are emotional do not download this demo!

Note: The demo requires a graphic card compatible with OpenGL 2.0+ (better to run it on VISTA or Windows 7)



About the demo:

  • Because the effects are cumulatives and requires a lot of matrix computations, they are slowing down the animation speed, to restore the initial speed, click on the "Restore to initial state" button.
  • The "Compass" and the "Rotation" track bar have the same effect.
  • You can click with the right mouse button to the "compass" or any track bar to restore the default value.
  • You can move all the objects (except the compass that is locked) with the mouse, including the 3D animation!
  • The compass allows you to hold down the left mouse button (in dragging mode) to change the rotation angle of the 3D object, this is a prefiguration of the visual gauges you can create with this version (using built-in polar coordinates to compute the rotation angle).
  • As long as i am aware of it, this is the first time that you can manipulate an OpenGL 3D object, altogether with GDI32/GDIPLUS in full composited mode, using multiple transparent layers, and region detection, inside of the same graphic container!
  • Version 5, allows you to use sprites with "multi-state", and you can change the active frame on the fly to perform static animation.
  • If you want you can create a composited picture directly in memory without using first a graphic container!
  • You can "clone" a 3D object while using distinct effects for each of the "clone": rotation angle, size, color, zoom factor, contrast, brightness, hue, alpha channel, z-order, XY location, etc.
  • Version 5.00 uses a dynamic skin theme UI, that is able to change the background on the fly either static or animated!

Note: Using real time 3D animated object takes more CPU resources than a standard OpenGL animation, because each of the frame must be rendered on the fly into a memory DIB buffer before it can be used as a layered sprite object. Thus the first purpose of the 3D feature is not to perform animation, but to map 2D picture onto 3D object to create 3D picture.

The PowerBASIC source code of this GDImage project is attached to this post:



...

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Marc Van Cauwenberghe

Once again unbelievable.

A small pause once in a while if I maximize the window. But otherwise very inpressive.

Marc

Petr Schreiber

Good work Patrice,

it looks very attractive!


Petr

P.S. PM sent
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Petr Schreiber

Thanks Patrice,

I have approximately 2x higher values, I guess that is because of single core CPU.
But it is still better than the original.


Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Patrice Terrier

#4
Petr,

Yes, there is a big diffrence between a single and a dual core processor, especialy in 3D graphic applications.

I can see this also in the WinDev SIMVIZ application when using OGRE and DirectX.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

The SDK source code of the GDImage 5.00 demo project is attached to the first post of this thread.

I have done some last minute enhancements  8)

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Elias Montoya


Good Work!!

Just one thing, when maximized, the degrees meter dissapears.

Oh wait... it just doesnt follow the needle... its there but stays in the literal position.

Patrice Terrier

Elias,

Good catch, i didn't think of that one, to fix it just add the code shown in red below:

SUB GdimageResize()
    LOCAL lpr AS RECT, nX, nY, nSizeX, nSizeY AS LONG, rZoomValue AS SINGLE
    CALL GDImageBackground()
    '// Compute new range
    CALL GDImageSetZoomRange(%GL_SizeX, %GL_SizeY, nSizeX, nSizeY)
    rZoomValue = (nSizeX / (%GL_SizeX / grAspect))
    CALL zSetTrackValue(zGetMainItem(%ID_TRACK_ZOOM), CLNG(rZoomValue * 1000))
    CALL zSetProperty(zGetMainItem(%ID_TRACK_ZOOM), %TRACK_DEFAULT_VALUE, CLNG(rZoomValue * 1000))
    CALL ZD_SetObjectScale(%IDS_3DOBJECT, rZoomValue)
    CALL GetClientRect(gnCtrl, lpr)

    nX = (lpr.nRight - %GL_SizeX) / 2
    nY = (lpr.nBottom - %GL_SizeY) / 2
    CALL ZD_SetObjectXY(%IDS_3DOBJECT, nX, nY, %FALSE)
    CALL ZD_SetObjectScale(%IDS_3DOBJECT, rZoomValue)

    CALL ZD_GetObjectBound(%IDS_ARROW, nSizeX, nSizeY)
    CALL ZD_SetObjectXY(%IDS_ARROW, lpr.nRight - nSizeX - 8, lpr.nBottom - nSizeY - 8, %FALSE)

    CALL ZD_GetObjectBound(%IDS_COMPASS, nSizeX, nSizeY)
    CALL ZD_SetObjectXY(%IDS_COMPASS, lpr.nRight - nSizeX - 8, lpr.nBottom - nSizeY - 8, %FALSE)

    CALL DisplayZoomValue()

END SUB
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

GDImage version 5.00 new API

3D sprite object
·     GL_AlphaBlend
·     GL_CreateContext
·     GL_CreateDrawingDC
·     GL_DeleteContext
·     GL_GLDC
·     GL_GLRC
·     GL_DrawCup
·     GL_DrawDome
·     GL_DrawCylinder
·     GL_DrawDisk
·     GL_DrawSphere
·     GL_DrawCube
·     GL_DrawCubeFrontFace
·     GL_DrawCubeBackFace
·     GL_DrawCubeTopFace
·     GL_DrawCubeBottomFace
·     GL_DrawCubeRightFace
·     GL_DrawCubeLeftFace

Disabled Window
·     ZI_CreateDW
·     ZI_DestroyDW
·     ZI_HideDW
·     ZI_ShowDW

GDImage callback
·     ZI_EventMessageEx
·     ZI_IsAnyArrowPressed

Conversion
·     ZI_CreateBitmapFromImage
·     ZI_CreateImageFromBitmap

Resizing
·     ZI_FitBitmapFromFile
·     ZI_FitImageToPaper

Utility
·     ZI_AlphaBlend
·     ZI_CreateDIBSection
·     ZI_MakeMultipleTexture
·     ZI_PaintBrushBitmap
·     ZI_RenderAttributes
·     ZI_SetImageFileOrientation

Common dialog settings
·     ZI_CenterDialog
·     ZI_SetLoadExtension
·     ZI_SetSaveExtension

GDIPLUS image attributes
·     ZI_RemapAlphaColor
·     ZI_RemapImageColor
·     ZI_SetImageAlpha
·     ZI_SetImageAttributeHue

Load GDIPLUS image from resource
·     ZI_ImageFromResource

Image composited
·     ZI_CreateImageComposited
·     ZI_CreateArrowObject
·     ZI_CreateBitmapObject
·     ZI_CreateCurveObject
·     ZI_CreateEllipseObject
·     ZI_CreatePolyLineObject
·     ZI_CreateRectangleObject
·     ZI_CreateTextObject

Background and Skin Theme
·     ZI_CreateSkinBackground
·     ZI_ImageTilePaint

Channel effect settings
·     ZD_SetObjectRed
·     ZD_GetObjectRed
·     ZD_SetObjectGreen
·     ZD_GetObjectGreen
·     ZD_SetObjectBlue
·     ZD_GetObjectBlue
·     ZD_SetObjectBrightness
·     ZD_GetObjectBrightness
·     ZD_SetObjectContrast
·     ZD_GetObjectContrast
·     ZD_RenderEffectToBitmapObject

Hollow sprite object
·     ZD_SetObjectHidden
·     ZD_IsObjectHidden

Bitmap multi-frame (static animation)
·     ZD_GetObjectFrameCount
·     ZD_SetObjectFrameCount
·     ZD_GetObjectFrameToUse
·     ZD_SetObjectFrameToUse

Anti red-eye
·     ZD_RemoveRedEyeFromBitmapObject
·     ZI_EnableCropRedEye
·     ZI_RemoveRedEye

Clock control
·     zClockCtrl

Registry
·     zGetReg
·     zSetReg

Helper
·     Rgb2Gray
·     ZD_ARGB
·     ZD_ComputeObjectAngleFromPoint
·     zAlphablend
·     zDrawImage
·     zBitmapToImage
 
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

#9
This is the second GDImage version 5.00 démo.

It uses one circular gauge, and three "clone" knob, this means that there is only one bitmap loaded whathever the number of knob being used.

You can rotate either the gauge or the knob using the left mouse button, in the demo they use all the same angle, but they could use a different one as well.



Note: This demo doesn't use OpenGL, but a "static" GDImage animation.

...


Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

The usual way to create a rotating knob, is to create a large bitmap embedding the different rotation angles of the knob.
While this works, it is a huge vaste of memory and it requires a rather complex computation to display the correct angle.

In comparison with GDImage, it requires only a small bitmap using two states:
state 1, is used to draw the background,
state 2, is used to draw the rotating part as a transparent overlay hover state 1.

You only need to use ZD_SetObjectFrameCount to specify the number of frame (2 in this example)
then ZD_SetObjectFrameToUse altogether with the ZD_CloneObject and you are done:

'   // The static Knob sprite 1.
    hBitmap = ZI_CreateBitmapFromFile(SK_FOLDER() + "BTN_Gauge01.png", nW, nH)
    CALL ZD_DrawBitmapToCtrl(gnCtrl, 100, 100, hBitmap, ZD_ColorARGB(255, 0), %IDS_KNOB1, %ZS_VISIBLE)'HIDDEN)
    CALL ZD_SetObjectLocked(%IDS_KNOB1, %TRUE)
    CALL ZD_SetObjectFrameCount(%IDS_KNOB1, 2)
    CALL ZD_SetObjectFrameToUse(%IDS_KNOB1, 1, %FALSE)
'   // The static Cursor sprite.
    CALL ZD_CloneObject(%IDS_KNOB1, %IDS_CURSOR1, 100, 100)
    CALL ZD_SetObjectLocked(%IDS_CURSOR1, %TRUE)
    CALL ZD_SetObjectFrameToUse(%IDS_CURSOR1, 2, %FALSE)




...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com