Okay I think I figured it out : unless going through a virtual raster, I shouldn't use raster bands but just CreatCopy.
Here's a working code for me :
#include <iostream>
#include "gdal_priv.h"
#include "cpl_conv.h" // for CPLMalloc()
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
GDALAllRegister();
GDALDatasetH poDataset;
poDataset = (GDALDataset *) GDALOpenShared( "n43.dt2", GA_ReadOnly );
if( poDataset == NULL )
{
return 0;
}
const char *pszFormat = "PNG";
GDALDatasetH resDataset;
GDALProgressFunc pfnProgress = GDALTermProgress;
GDALDriverH hDriver = GDALGetDriverByName( pszFormat );
const char *pszDest = "n43.png";
char **papszCreateOptions = NULL;
resDataset = GDALCreateCopy( hDriver, pszDest, poDataset,
FALSE, papszCreateOptions,
pfnProgress, NULL );
if( resDataset != NULL )
{
GDALClose( resDataset );
}
else
{
printf("Error creating output dataset.");
}
GDALClose(poDataset);
CSLDestroy( papszCreateOptions );
return 1;
}
This gives a slightly brighter PNG image than the one I get from using gdal_translate, I still need to figure out what's causing this. This works with JPEG images but the result cannot be read (I think it's an application specific format as it is called "JPEG JTIF" by gdalinfo --formats).