You can not access CB Gallery files directly. It deliberately protects direct access. You have to route through CB Gallery. To generate the URL you need the gallery entry and the gallery object. You can then generate it using the below, which handles both internal and external usages.
Code:
if ( $row->domain() ) {
$showPath = htmlspecialchars( $row->path() );
} else {
$showPath = $_CB_framework->pluginClassUrl( $plugin->element, true, array( 'action' => 'item', 'func' => 'show', 'id' => $row->get( 'id', 0, GetterInterface::INT ), 'gallery' => $gallery->id() ), 'raw', 0, true );
}
$row being the gallery entry and $gallery being the gallery object. Both are available in $items.php (assuming you're acting inside of the foreach loop for $rows).