Пример #1
0
int main()
{
	std::vector<uint8_t> buffer(width * 3 * height); // используй стандартные контейнеры, ну в самом-то деле
	const int radius = 300;

	uint8_t* pData = buffer.data();

	for (int i = 0; i < height; i++)
	{
		for (int j = 0; j < width; j++)
		{
			const bool isInside = (((height / 2 - i)*(height / 2 - i) + (width / 2 - j)*(width / 2 - j)) <= radius*radius);
			
			pData[0] = isInside ? (uint8_t)0		: 133;
			pData[1] = isInside ? (uint8_t)255		: 133;
			pData[2] = isInside ? (uint8_t)0		: 133;

			pData += 3;
		}
	}

	createBMP((uint8_t*)buffer.data(), width, height, depth, L"new_image.bmp");

	return 0;
}
Пример #2
0
/* Err... well, the pretty obvious sfscreate entry point
 *
 * return       : 1 on argument missing - 0 on success
 * variables    : A diskimage
 */
int main(int argc, char ** argv) {
    superblock   spb;
    bitmap       bpm;   // bitmap = 1 block
    file_entries fes;   // file entries  = 16 block
    file_entry   fie;   // temporary file entry
    file_content fic;   // file content  = 1000 block

    // You shall not pass alone !
    if (argc == 2 && (strcmp(argv[1], "-h") == 0 ||
                     (strcmp(argv[1], "--help") == 0))) {
        printf(HELP);
        printf(USAGE);
        return 1;
    } else if (argc != 2){
        printf(USAGE);
        return 1;
    }

    /* Checking filename */
    char * filename = checkFileName(argv[1]);

    // Initializing superblock
    createSuperBlock(&spb);

    // Initializing bitmap
    createBMP(&bpm);

    // Initializing file entries
    createFileEntries(&fes, &fie);

    // Initializing file content
    createFileContent(&fic);

    // Creating diskimage and writing down to it previously created elements
    printf(CREATEDISKIMG);
    FILE *fh = fopen (filename, "wb"); // w is write, b is ISO C compliance...
    if (fh != NULL) {
        fwrite (&spb, sizeof (superblock), 1, fh);
        fwrite (&bpm, sizeof (int8_t), BLOCK, fh);
        fwrite (&fes, sizeof (int8_t), 16*BLOCK, fh);
        fwrite (&fic, sizeof (int8_t), Max_block_file*BLOCK, fh);
        fclose (fh);
    }
    free(filename);
    return 0;
}
Пример #3
0
 inline void createBMPBordered(iXY pos, const char *imageName, const char *nToolTip, ITEM_FUNC nLeftClickFunc)
 {
     createBMP(pos, imageName, nToolTip, nLeftClickFunc, true);
 }