Sign in to follow this  
Followers 0
JohnOne

(Solved) BitWise op

6 posts in this topic

#1 ·  Posted (edited)

Is there any bitwise operation for this...

I have a colour 0x112233 and want to get to 332211?

basically rgb to bgr, and need it to be a number rather than a string via bitwise

EDIT:

I found something in c++

#define RGB2BGR(a_ulColor) (a_ulColor & 0xFF000000) | ((a_ulColor & 0xFF0000) >> 16) | (a_ulColor & 0x00FF00) | ((a_ulColor & 0x0000FF) << 16)

I just don't know anything about bitwise.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites



Here:

Func _ColorSwitch($color)
    Return BitOr(BitAnd($color, 0xFF000000), BitShift(BitAnd($color, 0x00FF0000), 16), BitAnd($color, 0x0000FF00), BitShift(BitAnd($color, 0xFF), -16))
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You can also try to take advantage of conversion functions:

Func BGRToRGB_OrWhateverThatIs($iColor)
    Return Dec(Hex(BinaryMid($iColor, 1, 3)))
EndFunc
Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

@trancexx

The "Dec(Hex(" looks like a red herring.

ConsoleWrite(_BGRToRGB_OrWhatever("0x332211") & @LF) ; A string
ConsoleWrite(_BGRToRGB_OrWhatever(0x332211) & @LF)   ; A number

;Returns:-
;0x112233
;0x112233

Func _BGRToRGB_OrWhatever($iColor)
    Return BinaryMid(Number($iColor), 1, 3)
EndFunc   ;==>_BGRToRGB_OrWhatever

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0