# Convert colors: BGR to RGB

**URL:** <https://forum.kirupa.com/t/convert-colors-bgr-to-rgb/249027>\
**Category:** flash\
**Created:** [January 14, 2008, 7:52pm UTC](https://forum.kirupa.com/t/convert-colors-bgr-to-rgb/249027 "2008-01-14T19:52:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ushka](https://avatars.discourse-cdn.com/v4/letter/u/258eb7/32.png) [@ushka](https://forum.kirupa.com/u/ushka)\
**Post date:** [January 14, 2008, 7:52pm UTC](https://forum.kirupa.com/t/convert-colors-bgr-to-rgb/249027/1 "2008-01-14T19:52:18Z")

</div>

[FONT=Arial][SIZE=2]I’ve searched a few times, but I can’t seem to find how to reverse this formula which takes Visual Basic’s BGR format and turns it into RGB:

```
var RGB = (color & 0x000000ff) &lt;&lt; 16 | (color & 0x0000FF00) | (color & 0x00FF0000) &gt;&gt; 16

```

I need to take the RGB and turn it into BGR to feed into VB.  
I’m sure it’s a simple bitwise operation, but I keep getting weird effects, like blue turns to green when it converts. I really appreciate any advice!

[/SIZE][/FONT]
