int main() { Bitmap bm; bm = bitmapCreate(10); if (!bm) { fprintf(stderr, "Failed to create bitmap.\n"); return 1; } bitmapPrint(bm); bitmapSet(&bm, 3); bitmapSet(&bm, 0); bitmapSet(&bm, 8); bitmapPrint(bm); bitmapUnset(&bm, 3); bitmapPrint(bm); bitmapClear(&bm); bitmapPrint(bm); bitmapDestroy(&bm); printf("End\n"); return 0; }
/* * Hlavní funkce konzolové aplikace */ int main(int argc, char **argv) { int result; lua_State* L = luaL_newstate(); luaL_openlibs(L); registerLuaFunctions(L); result = luaL_dofile(L, argv[1]); /* Zpracování chyby */ if (result != 0) { fprintf(stderr, "Error # %d\n", result); } else { /* the function name */ lua_getglobal(L, "save"); /* the first argument */ lua_pushstring(L, "images/"); /* call the function with 1 arguments, return 0 result */ lua_call(L, 1, 0); } printLuaStack(L); lua_close(L); bitmapDestroy(bmp); return (result != 0); }
int main(int argc,char *argv[]) { BM mainBM; OPTIONS options; LOCATIONHISTORY locationHistory; int error; //set vars to zero memset(&options, 0, sizeof(options)); //set all the option results to 0 memset(&mainBM, 0, sizeof(mainBM)); //Display introductory text PrintIntro(argv[0]); //locationHistory.jsonfilename="LocationHistory.json"; //default if (argc == 1) PrintUsage(argv[0]); //print usage instructions HandleCLIOptions(argc, argv, &options); PrintOptions(&options); RationaliseOptions(&options); //Initialise the bitmap bitmapInit(&mainBM, &options, &locationHistory); DrawGrid(&mainBM); //ColourWheel(mainBM, 100, 100, 100, 5); //Color wheel test of lines and antialiasing fprintf(stdout, "Loading locations from %s.\r\n", mainBM.options->jsonfilenamefinal); LoadLocations(&locationHistory, &mainBM.options->jsonfilenamefinal[0]); fprintf(stdout, "Plotting paths.\r\n"); PlotPaths(&mainBM, &locationHistory, &options); // HeatmapPlot(&mainBM, &locationHistory); fprintf(stdout, "Ploted lines between: %i points\r\n", mainBM.countPoints); printf("From:\t%s\r\n", asctime(localtime(&locationHistory.earliesttimestamp))); printf("To:\t%s\r\n", asctime(localtime(&locationHistory.latesttimestamp))); FreeLocations(&locationHistory); //Write the PNG file fprintf(stdout, "Writing to %s.\r\n", mainBM.options->pngfilenamefinal); error = lodepng_encode32_file(mainBM.options->pngfilenamefinal, mainBM.bitmap, mainBM.width, mainBM.height); if(error) fprintf(stderr, "LodePNG error %u: %s\n", error, lodepng_error_text(error)); //Write KML file fprintf(stdout, "Writing to %s.\r\n", mainBM.options->kmlfilenamefinal); WriteKMLFile(&mainBM); bitmapDestroy(&mainBM); fprintf(stdout, "Program finished."); return 0; }
void windowDeinit(void) { bitmapDestroy(s_pRestoreBuffer); bitmapDestroy(s_pBg); bitmapDestroy(s_pButtons); }
static int dbSelect(tableInfo *tbl, selectArgs *args, response *res, error *err) { char *columnName = args->columnName; printf("Selecting from column '%s'...\n", columnName); char *varName = args->varName; if (varName == NULL || strcmp(varName, "") == 0) { ERROR(err, E_BADARG); goto exit; } // Retrieve the column from disk column *col = (column *) malloc(sizeof(column)); if (col == NULL) { ERROR(err, E_NOMEM); goto exit; } if (columnReadFromDisk(tbl, columnName, col, err)) { free(col); goto exit; } // columnPrint(col, "read column from disk in dbSelect"); // Get result bitmap struct bitmap *resultBmp; if (args->hasCondition) { if (args->isRange) { if (columnSelectRange(col, args->low, args->high, &resultBmp, err)) { goto cleanupColumn; } } else { if (columnSelectValue(col, args->low, &resultBmp, err)) { goto cleanupColumn; } } } else { if (columnSelectAll(col, &resultBmp, err)) { goto cleanupColumn; } } // Add variable-bitmap pair to varmap if (varMapAddVar(varName, VAR_BMP, resultBmp, err)) { goto cleanupBitmap; } // varMapPrint("updated var map in dbSelect", err); printf("Added variable '%s'\n", varName); RESPONSE_SUCCESS(res); columnDestroy(col); return 0; cleanupBitmap: bitmapDestroy(resultBmp); cleanupColumn: columnDestroy(col); exit: return 1; }
static int dbLoopJoin(joinArgs *args, response *res, error *err) { char *oldVar1 = args->oldVar1; char *oldVar2 = args->oldVar2; char *newVar1 = args->newVar1; char *newVar2 = args->newVar2; if (oldVar1 == NULL || oldVar2 == NULL || newVar1 == NULL || newVar2 == NULL) { ERROR(err, E_BADARG); goto exit; } // Get the results from the old var names fetchResults *fResults1; fetchResults *fResults2; if (obtainResults(oldVar1, &fResults1, err) || obtainResults(oldVar2, &fResults2, err)) { goto exit; } int nResults1 = fResults1->nResultEntries; int nResults2 = fResults2->nResultEntries; if (nResults1 == 0 || nResults2 == 0) { ERROR(err, E_VAREMT); goto exit; } // Create bitmaps to store results of joins struct bitmap *bmp1; struct bitmap *bmp2; if (bitmapCreate(fResults1->nColumnEntries, &bmp1, err)) { goto exit; } if (bitmapCreate(fResults2->nColumnEntries, &bmp2, err)) { bitmapDestroy(bmp1); goto exit; } // Determine smaller and larger results fetchResults *smallerFResults; fetchResults *largerFResults; struct bitmap *smallerBmp; struct bitmap *largerBmp; char *smallerNewVar; char *largerNewVar; if (nResults1 < nResults2) { smallerFResults = fResults1; smallerBmp = bmp1; smallerNewVar = newVar1; largerFResults = fResults2; largerBmp = bmp2; largerNewVar = newVar2; } else { smallerFResults = fResults2; smallerBmp = bmp2; smallerNewVar = newVar2; largerFResults = fResults1; largerBmp = bmp1; largerNewVar = newVar1; } // Loop and fill bitmaps for (int i = 0; i < largerFResults->nResultEntries; i++) { for (int j = 0; j < smallerFResults->nResultEntries; j++) { if (largerFResults->results[i] == smallerFResults->results[j]) { if (bitmapMark(largerBmp, largerFResults->indices[i], err) || bitmapMark(smallerBmp, smallerFResults->indices[j], err)) { goto cleanupBitmaps; } } } } // Add bitmaps to varmap using new var names if (varMapAddVar(smallerNewVar, VAR_BMP, smallerBmp, err) || varMapAddVar(largerNewVar, VAR_BMP, largerBmp, err)) { goto cleanupBitmaps; } printf("Added variables '%s' and '%s'\n", smallerNewVar, largerNewVar); RESPONSE_SUCCESS(res); return 0; cleanupBitmaps: bitmapDestroy(bmp1); bitmapDestroy(bmp2); exit: return 1; }