# VC4 image movement

**URL:** <https://community.br-automation.com/t/vc4-image-movement/2392>\
**Category:** HMI & Visualization\
**Tags:** vc4\
**Created:** [February 29, 2024, 7:22am UTC](https://community.br-automation.com/t/vc4-image-movement/2392 "2024-02-29T07:22:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![hasan\_arguc](https://avatars.discourse-cdn.com/v4/letter/h/FF8800/32.png) [@hasan\_arguc](https://community.br-automation.com/u/hasan_arguc)\
**Post date:** [February 29, 2024, 7:22am UTC](https://community.br-automation.com/t/vc4-image-movement/2392/1 "2024-02-29T07:22:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kovarj](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/kovarj/32/537_2.png) [@kovarj](https://community.br-automation.com/u/kovarj)\
**Post date:** [February 29, 2024, 7:30am UTC](https://community.br-automation.com/t/vc4-image-movement/2392/2 "2024-02-29T07:30:55Z")

</div>

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](https://help.br-automation.com/#/en/4/libraries%2Fvisapi%2Ffbks%2Fvisapi_draw.html)

---

<div class="post-metadata">

**Author:** ![hasan\_arguc](https://avatars.discourse-cdn.com/v4/letter/h/FF8800/32.png) [@hasan\_arguc](https://community.br-automation.com/u/hasan_arguc)\
**Post date:** [February 29, 2024, 10:22am UTC](https://community.br-automation.com/t/vc4-image-movement/2392/3 "2024-02-29T10:22:43Z")

</div>

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.

 ![bandicam 2024-02-29 13-15-13-072](https://europe1.discourse-cdn.com/brcommunity/original/2X/6/64dda027118047201e971638d78bd58132725d0e.jpeg)

#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))*/

```

}

---

<div class="post-metadata">

**Author:** ![kovarj](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/kovarj/32/537_2.png) [@kovarj](https://community.br-automation.com/u/kovarj)\
**Post date:** [February 29, 2024, 10:59am UTC](https://community.br-automation.com/t/vc4-image-movement/2392/4 "2024-02-29T10:59:40Z")

</div>

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](https://help.br-automation.com/#/en/4/projectmanagement%2Fsystemconfiguration%2Fsg4%2Fcpu%2Fprojectorganisation_systemconfiguration_sg4_cpu_files.html)

 ![FileReference](https://europe1.discourse-cdn.com/brcommunity/original/2X/1/1eb3a0f17889e79330ddffaff0a14720664cd966.jpeg)

Also make sure that you have your files in userPartion 🙂 [B&R Online Help](https://help.br-automation.com/#/en/4/automationruntime/enhancedtransfer/handling/settings/et_settingsbeforebuild.html)

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

---

<div class="post-metadata">

**Author:** ![hasan\_arguc](https://avatars.discourse-cdn.com/v4/letter/h/FF8800/32.png) [@hasan\_arguc](https://community.br-automation.com/u/hasan_arguc)\
**Post date:** [February 29, 2024, 2:54pm UTC](https://community.br-automation.com/t/vc4-image-movement/2392/5 "2024-02-29T14:54:51Z")

</div>

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 ☹

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).

---

<div class="post-metadata">

**Author:** ![kovarj](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/kovarj/32/537_2.png) [@kovarj](https://community.br-automation.com/u/kovarj)\
**Post date:** [February 29, 2024, 3:13pm UTC](https://community.br-automation.com/t/vc4-image-movement/2392/6 "2024-02-29T15:13:07Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![christoph.hilchenbac](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/christoph.hilchenbac/32/423_2.png) [@christoph.hilchenbac](https://community.br-automation.com/u/christoph.hilchenbac)\
**Post date:** [February 29, 2024, 3:24pm UTC](https://community.br-automation.com/t/vc4-image-movement/2392/7 "2024-02-29T15:24:23Z")

</div>

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](https://help.br-automation.com/#/en/4/visualization%2Fviscompvc4%2Fcontrols%2Fcontrol_slider.html)

---

<div class="post-metadata">

**Author:** ![hasan\_arguc](https://avatars.discourse-cdn.com/v4/letter/h/FF8800/32.png) [@hasan\_arguc](https://community.br-automation.com/u/hasan_arguc)\
**Post date:** [March 4, 2024, 8:51am UTC](https://community.br-automation.com/t/vc4-image-movement/2392/8 "2024-03-04T08:51:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kovarj](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/kovarj/32/537_2.png) [@kovarj](https://community.br-automation.com/u/kovarj)\
**Post date:** [March 4, 2024, 9:53am UTC](https://community.br-automation.com/t/vc4-image-movement/2392/9 "2024-03-04T09:53:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hasan\_arguc](https://avatars.discourse-cdn.com/v4/letter/h/FF8800/32.png) [@hasan\_arguc](https://community.br-automation.com/u/hasan_arguc)\
**Post date:** [March 6, 2024, 12:53pm UTC](https://community.br-automation.com/t/vc4-image-movement/2392/10 "2024-03-06T12:53:06Z")

</div>

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](https://europe1.discourse-cdn.com/brcommunity/original/2X/7/7bab379cd27f1b278ebc273af5295997d6e80343.jpeg)

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))*/

```

}

---

<div class="post-metadata">

**Author:** ![kovarj](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/kovarj/32/537_2.png) [@kovarj](https://community.br-automation.com/u/kovarj)\
**Post date:** [March 21, 2024, 5:21pm UTC](https://community.br-automation.com/t/vc4-image-movement/2392/11 "2024-03-21T17:21:56Z")

</div>

Hi @hasan_arguc ,

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
