VC4 image movement

Hi,

I am using AS 4.12.5.95 , I4.93 RunTime , V4.72.6 Visual Component.
I need image or any object movement on VC4 but i did not find it.
Could you share me any sample program about it.

Thanks.

1 Like

You can either create list of images, layer them and change visibility/index (e.g. fun turning etc) or if you would like really have dynamic visu then Visapi library is the right one. B&R Online Help

Thanks for response,

I am trying below Ansi C code like that but uiErrorBitmapFromFile gives 7196 error number (file does not exist).

I have sure that file exist and path current.

#include <bur/plctypes.h>
#include <visapi.h>

#ifdef _DEFAULT_INCLUDES
#include <AsDefault.h>
#endif

void _CYCLIC Program1Cyclic(void)
{
if (!ready)
{
VC_HANDLE = VA_Setup(1 , “Visu”);

	if (VC_HANDLE)
		ready = 1;
}

if (!VA_Saccess(1,VC_HANDLE))
{
	switch (uiStepBitmapFromFile)
	{
		case 0: /* Initialize the clip border*/
			pBitmap = 0;
			iClipX1 = 0;
			iClipY1 = 0;
			iClipX2 = 200;
			iClipY2 = 200;
			iDestX = iClipX1;
			iDestY = iClipY1;
			uiStepBitmapFromFile = 1;
			break;

		case 1: /*Load the PNG graphic*/
			uiErrorBitmapFromFile=VA_LoadBitmap(1, VC_HANDLE, "C:\Obje" , "Stick.png",(UDINT)&pBitmap);
           
			if (!uiErrorBitmapFromFile)
				uiStepBitmapFromFile = 2;
			break;
        
		case 2: /* Blit bitmap */
			uiErrorBitmapFromFile = VA_BlitBitmap(1, VC_HANDLE, (UDINT)pBitmap, iDestX, iDestY, iClipX1, iClipY1, iClipX2, iClipY2, 1);
            
			if (!uiErrorBitmapFromFile)
				uiStepBitmapFromFile = 3;
			break;

		case 3: /*Free bitmap*/
			uiErrorBitmapFromFile=VA_FreeBitmap(1, VC_HANDLE, (UDINT)&pBitmap);
                       
			if (!uiErrorBitmapFromFile)
				uiStepBitmapFromFile = 0;
			break;
	}/*switch (uiStepBitmapFromFile)*/
    
	VA_Srelease(1, VC_HANDLE);
}/*(!VA_Saccess(1, VC_HANDLE))*/

}

It is not allowed to use path, you should use FileDevice name and configure path inside. usDevice input of FUB expects STRING to FileDevice name provided as a pointer B&R Online Help

Also make sure that you have your files in userPartion :slight_smile: B&R Online Help

PS: pictures to user partion you can download using ftp or during project transfer.

Thank you so much for your help,

I think now we very close to solve the problem.

uiErrorBitmapFromFile gives 7197 ( Invalid file format) error code. so I think problem about our Stick.png image format. B&R help advise VCBitmapConverter.exe application and we find this application but we did not achieve to use :frowning:

To save graphics (GIF, BMP, JPG) as a PNG file using the color palette being used in the VC editor, it is possible to use the tool VCBitmapConverter.exe available in the Automation Studio installation directory (…AS\VC\Tools).

Visapi error code 7197 is returned by VA_LoadBitmap when a PNG file with 24-bit color depth is attempted to load. This function only supports PNG files with 8-bit or less color depth. To resolve this error, convert the PNG file to 8-bit or less color depth using a graphics editor and try loading it again with VA_LoadBitmap. I would recommend Gimp :slight_smile:

1 Like

if either vertical or horizontal movement is sufficient you can use an own image for a slider’s thumb.

https://help.br-automation.com/#/en/4/visualization%2Fviscompvc4%2Fcontrols%2Fcontrol_slider.html

Thank you for kindly response it’s working anymore:)

Please mark which solution you have used in the end. It will help others :slight_smile:

Sorry for being late return.

Here is necessary settings below.

I have used 32 bit PNG image for good quality. 8 bit not good.

BR Visu image call

Unfortunately, an uninterrupted flow cannot be achieved.

VAR
ready : UINT :=0;
VC_HANDLE : UDINT :=0;
pBitmap : REFERENCE TO sVCBitmap;
uiStepBitmapFromFile :UINT :=0;
iDestX :INT :=0;
iDestY :INT :=0;
iClipX1 :INT :=0;
iClipY1 :INT :=0;
iClipX2 :INT :=0;
iClipY2 :INT :=0;
uiErrorBitmapFromFile :UINT :=0;
END_VAR

#include <bur/plctypes.h>
#include <visapi.h>

#ifdef _DEFAULT_INCLUDES
    #include <AsDefault.h>
#endif

void _CYCLIC SampleCyclic(void)
{
if (!ready)
{
VC_HANDLE = VA_Setup(1 , “visloc”);

    if (VC_HANDLE)
        ready = 1;

}

if (!VA_Saccess(1,VC_HANDLE))
{
switch (uiStepBitmapFromFile)
{
case 0: /* Initialize the clip border*/
pBitmap = 0;
iClipX1 = 0;
iClipY1 = 0;
iClipX2 = 200;
iClipY2 = 200;
iDestX = iClipX1;
iDestY = iClipY1;
uiStepBitmapFromFile = 1;
break;

               case 1: /*Load the PNG graphic*/
           uiErrorBitmapFromFile=VA_LoadBitmap(1, VC_HANDLE, "DISK", "cpu.png",(UDINT)&pBitmap);
           
            if (!uiErrorBitmapFromFile)
               uiStepBitmapFromFile = 2;
        break;
        
        case 2: /* Blit bitmap */
           uiErrorBitmapFromFile = VA_BlitBitmap(1, VC_HANDLE, (UDINT)pBitmap, iDestX, iDestY, iClipX1, iClipY1, iClipX2, iClipY2, 1);
            
           if (!uiErrorBitmapFromFile)
               uiStepBitmapFromFile = 3;
        break;

        case 3: /*Free bitmap*/
           uiErrorBitmapFromFile=VA_FreeBitmap(1, VC_HANDLE, (UDINT)&pBitmap);
                       
                      if (!uiErrorBitmapFromFile)
               uiStepBitmapFromFile = 0;
        break;
    }/*switch (uiStepBitmapFromFile)*/
    
    VA_Srelease(1, VC_HANDLE);
}/*(!VA_Saccess(1, VC_HANDLE))*/

}

Hi @c513531 ,

It looks like you got some good suggestions from other community members, and it has been a couple of weeks since the last activity on this post. Can you please mark the reply that helped you the most as the solution? Or if you still have open questions on this topic, can you please provide an update?

Jaroslav