Не пойму в чем проблема, программа отрабатывает без ошибок, но изображение заполняется диагональным крестом на сером фоне, как при отсутствии значка с таким кодом??? Значек с таким кодом существует, в чем проблема?
Вот код:
Код |
---|
int
main(int argc, char **argv)
{
int rc = 0;
HRSC hrsc = 0;
HMAP hmap = 0;
HSITE hsite = 0;
const char *mapname;
RECT rect = {0, };
XCONTEXT FxDC = {0, };
MAPREGISTER map;
LISTREGISTER sheet;
CREATESITE createsite;
QApplication app(argc, argv);
QMainWindow *mw;
mw = new QMainWindow();
QPixmap pixmap(mw->width(), mw->height());
pixmap.fill("red");
mw->setBackgroundPixmap(pixmap);
mw->show();
app.setMainWidget(mw);
/* Open map data */
if ((hmap = mapOpenData(MKCL_MAPFILENAME))
== 0)
{
fprintf(stderr, "ERROR: Can't open map\n");
rc = EINVAL;
goto invalid_exit;
}
/* Create and append site */
memset(&map, 0, sizeof(MAPREGISTER));
memset(&sheet, 0, sizeof(LISTREGISTER));
memset(&createsite, 0, sizeof(CREATESITE));
if(mapGetMapInfo(hmap, 1, &map, &sheet) == 0)
{
fprintf(stderr, "ERROR: Can't get map description\n");
rc = EINVAL;
goto invalid_exit;
}
mapname = mapGetMapName(hmap);
if (mapname == NULL)
{
fprintf(stderr, "ERROR: Can't get map name\n");
rc = EINVAL;
goto invalid_exit;
}
createsite.Length = sizeof(CREATESITE);
memcpy(createsite.MapName, mapname, sizeof(createsite.MapName)-1);
createsite.MapType = map.MapType;
createsite.MaterialProjection = map.MaterialProjection;
createsite.Scale = map.Scale;
createsite.FirstMainParallel = map.FirstMainParallel;
createsite.SecondMainParallel = map.SecondMainParallel;
createsite.AxisMeridian = map.AxisMeridian;
createsite.MainPointParallel = map.MainPointParallel;
if ((hsite = mapCreateAndAppendSite(hmap, "./test.sit", argv[MKCL_RSCFILENAME], &createsite)) == 0)
{
fprintf(stderr, "ERROR: Can't create temporary site\n");
rc = EINVAL;
goto invalid_exit;
}
FxDC.xcDisplay = pixmap.x11AppDisplay();
FxDC.xcWindow = pixmap.handle();
FxDC.xcContext = XCreateGC(FxDC.xcDisplay, FxDC.xcWindow, 0, NULL);
FxDC.xcPoint.X = 0;
FxDC.xcPoint.Y = 0;
rect.left = 0;
rect.top = 0;
rect.right = 40;
rect.bottom = 40;
if (mapPaintExampleSiteObject(hmap, hsite, (unsigned int)&FxDC, &rect, 10101010) == 0)
{
fprintf(stderr, "ERROR: Can't paint object\n");
rc = EINVAL;
goto invalid_exit;
}
if (!pixmap.isNull())
pixmap.save("./test.bmp", "BMP");
else
fprintf(stderr, "Image wasn't painted\n");
rc = app.exec();
invalid_exit:
if (FxDC.xcContext != NULL)
XFreeGC(FxDC.xcDisplay, FxDC.xcContext);
delete mw;
if (hrsc != 0)
mapCloseRsc(hrsc);
if (hmap != 0)
mapCloseData(hmap);
return rc;
}
|
PS: Документацию скачал, изучаю, спасибо! )