They're bitfields, not serialized values, so if you have the permission number for a group (and it could very well be 3), then you can check it by using
PHP Code:
if ($vbulletin->usergroupcache[12]['gallery'] & $vbulletin->bf_ugp['gallery']['vote'])
{
// they have vote permission
}
I don't know if $vbulletin->usergroupcache[12]['gallery'] is right or not. It's not clear from what's posted above.