예제 #1
0
static void fuzz_drawImage(Fuzz* fuzz) {
    SkPaint p;
    init_paint(fuzz, &p);
    sk_sp<SkSurface> surface;
    init_surface(fuzz, &surface);
    SkBitmap bmp;
    init_bitmap(fuzz, &bmp);

    sk_sp<SkImage> image(SkImage::MakeFromBitmap(bmp));

    bool bl;
    fuzz->next(&bl);
    SkScalar a, b;
    fuzz->next(&a, &b);
    if (bl) {
        surface->getCanvas()->drawImage(image, a, b, &p);
    }
    else {
        SkRect dst = SkRect::MakeWH(a, b);
        fuzz->next(&a, &b);
        SkRect src = SkRect::MakeWH(a, b);
        uint8_t x;
        fuzz->nextRange(&x, 0, 1);
        SkCanvas::SrcRectConstraint cst = (SkCanvas::SrcRectConstraint)x;
        surface->getCanvas()->drawImageRect(image, src, dst, &p, cst);
    }
}
예제 #2
0
void init_filesystem( char * filesystem_name, masterBootRecord * mbr){
	
	/*mbr sector*/
	mbr->existFS = 1;
	write_disk(vDisk->disk, 0,mbr,BLOCK_SIZE,0);
	
	/* superBlock sector */
	superblock->name = "Chinux";
	superblock->blockSize = BLOCK_SIZE;
	superblock->freeBlocks = 10000;//TODO:PONER LA CANTIDAD POSTA.
	superblock->usedBlocks = 0;
	superblock->root = NULL; 
	write_disk(vDisk->disk,1,superblock,sizeof(masterBlock),0);

	/* bitmap Sectors */
	init_bitmap();
	
	/* inodemap Sectors */
 	init_inodemap();

	/* Root node & current node */
	
	init_root();
	write_disk(vDisk->disk,1,superblock,512,0);
	current = superblock->root;

	return;
}
예제 #3
0
int main()
{
    printf("init result:%d\n", init_bitmap(34, &bitmap_objects));

    dump_bitmap(&bitmap_objects);
    printf("firt set result:%d\n", first_set_index(&bitmap_objects));

    OBJECT_TYPE *obj = NULL;
    for (int i = 0; i < bitmap_objects.num_of_objs; ++i) {
    //for (int i = 0; i < 30; ++i) {
        obj = alloc_obj(&bitmap_objects);
    }
    dump_bitmap(&bitmap_objects);

    printf("firt set result:%d\n", first_set_index(&bitmap_objects));
    obj = bitmap_objects.objects;
    //for (int i = 0; i < bitmap_objects.num_of_objs; ++i) {
    for (int i = 0; i < 30; ++i) {
        free_obj(&bitmap_objects, obj++);
    }
    printf("firt set result:%d\n", first_set_index(&bitmap_objects));
    dump_bitmap(&bitmap_objects);
    printf("firt set result:%d\n", first_set_index(&bitmap_objects));
    free_obj(&bitmap_objects, obj++);
    free_obj(&bitmap_objects, obj++);
    free_obj(&bitmap_objects, obj++);
    free_obj(&bitmap_objects, obj++);
    printf("firt set result:%d\n", first_set_index(&bitmap_objects));
    printf("uninit result:%d\n", uninit_bitmap(&bitmap_objects));
}
예제 #4
0
int main(int argc, char* argv[])
{
	if (argc < 2) {
		printf("Usage %s [taskid] [otherid...] \n", argv[0]);
		exit(1);
	}
	Bitmap* bitmap = init_bitmap();

	write2bitmap(bitmap, argv[1], 1);
	
	int i;
	for (i = 2; i < argc; i++) {
	}

	char* newFile = malloc(sizeof(argv[1]));
	strcpy(newFile, argv[1]);
	
	FILE* fh = fopen(strcat(newFile, "_diff"), "w");
	uint64_t offset;
	for (offset = 0; offset < bitmap->maxpos+1; offset++) {
		if (get_bit(bitmap, offset)) {
			fprintf(fh, "%u\n", offset);
		}
	}

	fclose(fh);
	
	free(newFile);

	free_bitmap(bitmap);

	return EXIT_SUCCESS;
}
예제 #5
0
struct m_bitmap *mbm_create_bitmap(uint32_t size, char *filename, uint64_t offset)
{
	assert((size % BITMAP_WIDTH) == 0);

	struct m_bitmap *bm = malloc(sizeof(struct m_bitmap));
	assert(bm);

	bm->size = size;
	bm->low_map = malloc(size * sizeof(uint64_t));
	memset(bm->low_map, 0, size * sizeof(uint64_t));

	if (filename != NULL) {
		strncpy(bm->filename, filename, MAX_FILE_NAME);
		bm->fd = open(bm->filename, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
		assert(bm->fd > 0);
		lseek(bm->fd, offset, SEEK_SET);
		
		//TODO: write the magic number and advance by 32 bytes
		//for the reserved bits. For now, just advance by 40 bytes
		lseek(bm->fd, 40, SEEK_CUR);
		
		write(bm->fd, &(bm->size), sizeof(bm->size)); 
		write(bm->fd, bm->low_map, size * sizeof(uint64_t));
	} else {
		/* non-persistent bitmap */
		bm->fd = -1;
	}

	init_bitmap(bm);
	return bm;
}
예제 #6
0
static void fuzz_drawBitmap(Fuzz* fuzz) {
    SkPaint p;
    init_paint(fuzz, &p);
    sk_sp<SkSurface> surface;
    init_surface(fuzz, &surface);
    SkBitmap bmp;
    init_bitmap(fuzz, &bmp);

    SkScalar a, b;
    fuzz->next(&a, &b);
    surface->getCanvas()->drawBitmap(bmp, a, b, &p);
}
예제 #7
0
static SkBitmap make_argb8888_gradient() {
    SkBitmap bitmap;
    init_bitmap(kPMColor_SkColorType, &bitmap);
    uint8_t rowColor = 0;
    for (int y = 0; y < SLIDE_SIZE; y++) {
        uint32_t* dst = bitmap.getAddr32(0, y);
        for (int x = 0; x < SLIDE_SIZE; x++) {
            dst[x] = SkPackARGB32(rowColor, rowColor,
                                  rowColor, rowColor);
        }
        if (y % PIXEL_SIZE_8888 == PIXEL_SIZE_8888 - 1) {
            rowColor++;
        }
    }
    return bitmap;
}
예제 #8
0
static SkBitmap make_argb4444_gradient() {
    SkBitmap bitmap;
    init_bitmap(kARGB_4444_SkColorType, &bitmap);
    uint8_t rowColor = 0;
    for (int y = 0; y < SLIDE_SIZE; y++) {
        uint16_t* dst = bitmap.getAddr16(0, y);
        for (int x = 0; x < SLIDE_SIZE; x++) {
            dst[x] = SkPackARGB4444(rowColor, rowColor,
                                    rowColor, rowColor);
        }
        if (y % PIXEL_SIZE_4444 == PIXEL_SIZE_4444 - 1) {
            rowColor++;
        }
    }
    return bitmap;
}
예제 #9
0
void init_filesystem(char * filesystem_name, masterBootRecord * mbr) {

	/*mbr sector*/
	int fd;

	user * users = calloc(sizeof(user), 100);

	memcpy(users[0].name, "chinux", str_len("chinux"));
	memcpy(users[0].password, "chinux", str_len("chinux"));
	users[0].usrID = 1;
	users[0].group = ADMIN;
	mbr->existFS = 1;

	write_disk(0, MBRSECTOR, mbr, BLOCK_SIZE, 0); //BLOCK_SIZE

	/* superBlock sector */
	superblock->name = "Chinux";
	superblock->blockSize = BLOCK_SIZE;
	superblock->freeBlocks = DISK_SIZE / BLOCK_SIZE;
	superblock->usedBlocks = 0;
	superblock->root = NULL;
	write_disk(0, SUPERBLOCKSECTOR, superblock, BLOCK_SIZE, 0);

	/* bitmap Sectors */
	init_bitmap();

	/* inodemap Sectors */
	init_inodemap();

	/* Root node & current node */

	init_root();

	write_disk(0, 1, superblock, BLOCK_SIZE, 0);

	current = superblock->root;

	makeDir("users");
	makeDir("etc");

	fd = do_creat("usersfile", 777);
	write(fd, (char *) users, sizeof(user) * 100);
	close(fd);

	return;
}
예제 #10
0
static SkBitmap make_argb4444_stripes() {
    SkBitmap bitmap;
    init_bitmap(kARGB_4444_SkColorType, &bitmap);
    uint8_t rowColor = 0;;
    for (int y = 0; y < SLIDE_SIZE; y++) {
        uint16_t* dst = bitmap.getAddr16(0, y);
        for (int x = 0; x < SLIDE_SIZE; x++) {
            dst[x] = SkPackARGB4444(rowColor, rowColor,
                                    rowColor, rowColor);
        }
        if (rowColor == 0) {
            rowColor = 15;
        } else {
            rowColor = 0;
        }
    }
    return bitmap;
}
예제 #11
0
static SkBitmap make_argb8888_stripes() {
    SkBitmap bitmap;
    init_bitmap(kPMColor_SkColorType, &bitmap);
    uint8_t rowColor = 0;
    for (int y = 0; y < SLIDE_SIZE; y++) {
        uint32_t* dst = bitmap.getAddr32(0, y);
        for (int x = 0; x < SLIDE_SIZE; x++) {
            dst[x] = SkPackARGB32(rowColor, rowColor,
                                  rowColor, rowColor);
        }
        if (rowColor == 0) {
            rowColor = 255;
        } else {
            rowColor = 0;
        }
    }
    return bitmap;
}
예제 #12
0
파일: gr.c 프로젝트: iruka-/ORANGEpico
//	====================================================
//	グラフィック初期化.
//	====================================================
void gr_init(int width,int height,int bpp,int color)
{
	//static
	int first = 1;

	width = (width + 3) & (-4);	//4の倍数にする.

	memset(&gr,0,sizeof(gr));
	gr.width  = width;
	gr.height = height;
	gr_settitle("picmon");

	gr.client_rect.left  = 32;
	gr.client_rect.top   = 32;

	gr.client_rect.right  = gr.client_rect.left + width;
	gr.client_rect.bottom = gr.client_rect.top  + height;

	gr.end_flag = 0;

	if(first) {
		DWORD thid;

		atexit(gr_close);
		first = 0;
		gr.close_flag = 0;

		gr.esc_event       = CreateEvent(NULL, FALSE, TRUE, NULL);
		gr.hitanykey_event = CreateEvent(NULL, FALSE, TRUE, NULL);
		gr.cw_event        = CreateEvent(NULL, FALSE, FALSE, NULL);
		gr.paint_event     = CreateEvent(NULL, FALSE, FALSE, NULL);
		gr.thread = CreateThread(NULL, 0, xmain, NULL, 0, &thid);
		if(gr.thread == NULL) {
			fprintf(stderr, "Can't create thread.\n");
			exit(EXIT_FAILURE);
		}
		WaitForSingleObject(gr.cw_event, INFINITE);
	}
	init_bitmap(bpp);
}
예제 #13
0
struct m_bitmap* mbm_load_bitmap(char *filename, uint64_t offset)
{
	struct m_bitmap *bm = malloc(sizeof(struct m_bitmap));
	assert(bm);
	int ret = 0;

	bm->fd = open(filename, O_RDWR);
	assert(bm->fd > 0);
	lseek(bm->fd, offset, SEEK_SET);
	
	//TODO: Verify magic number, advance by 32 unused bytes.
	lseek(bm->fd, 40, SEEK_CUR);
	
	ret = read(bm->fd, &(bm->size), sizeof(uint64_t));
	bm->low_map = malloc(bm->size * sizeof(uint64_t));
	
	//TODO: write the magic number
	ret = read(bm->fd, bm->low_map, bm->size * sizeof(uint64_t));
	strncpy(bm->filename, filename, MAX_FILE_NAME);

	init_bitmap(bm);
	return bm;
}
예제 #14
0
bool init_bitmap_from_main_window(NSSize sz) {
    fprintf(stderr,"Window size %.3f x %.3f\n",sz.width,sz.height);

    return init_bitmap(ceil(sz.width),ceil(sz.height));
}
예제 #15
0
void render_subtitle_teletext(xmlsubsParseState *state) {
  bitmap_t my_bitmap;
  int row,col;
  unsigned char ch;
  int fgcolour,bgcolour;
  char filename[20];
  int font_x,font_y;
  int bitmap_x,bitmap_y;
  int x,y;
  unsigned char q;
  int i;
  int colour_used[8];

  for (i=0;i<8;i++) { colour_used[i]=0; }

  init_bitmap(&my_bitmap,720,576,8);  // 8 is used for transparency (0x999999)
  bgcolour=0; // Black background
  colour_used[bgcolour]=1;
  for (row=0;row<24;row++) {
    for (col=0;col<40;col++) {
      ch=iso2vtx[state->subtitle.text[row][col]&0xff];
      if (ch) {
        fgcolour=state->subtitle.colours[row][col];
        colour_used[fgcolour]=1;
        font_x=(ch % 32)*15;
        font_y=(ch/32)*18;
        bitmap_x=col*15+(720-(40*15))/2;
        bitmap_y=row*18+(576-(24*18))/2;

/* GIF is 480x144, and contains 32x8 characters */
/* Each character is 15x18 - we double it to 15x30*/

        for (x=0;x<15;x++) {
          for (y=0;y<36;y+=2) {
            i=480*(font_y+(y/2))+(font_x+x);
            if (i >= sizeof(vtx15x18)) {
              fprintf(stderr,"ERROR: row=%d, col=%d, size=%d, i=%d, font_x+x=%d, font_y+y=%d\n",row,col,sizeof(vtx15x18),i,font_x+x,font_y+y/2); 
              exit(1);
            }
            q=vtx15x18[i];
            if (q=='.') { q=bgcolour; } else { q=fgcolour; }
            my_bitmap.buffer[720*(bitmap_y+y)+(bitmap_x+x)]=q;
            my_bitmap.buffer[720*(bitmap_y+y+1)+(bitmap_x+x)]=q;
          }
        }
      }
    }
  }
  sprintf(filename,"sub%05d.png",state->subtitle_number);
  write_png(&my_bitmap,filename,ttxt_palette,ttxt_trans,9);

  x=1; // Transparent
  for (i=0;i<8;i++) x+=colour_used[i];

  if (x > 4) { 
    fprintf(stderr,"WARNING: %d colours needed in SPU starting at %s\n",x,state->start);
    printf("<!-- WARNING: %d colours needed in following SPU -->\n",x);
  }

  fprintf(stderr,"%s\r",state->start);
  printf("<spu");
  if (state->start[0]) { printf(" start=\"%s\"",state->start); }
  if (state->end[0]) { printf(" end=\"%s\"",state->end); }
  printf(" image=\"%s\" />\n",filename);
}
예제 #16
0
int main(int argc,char **argv) {
    WNDCLASS wnd;
    HRESULT hr;
    RECT rect;
    MSG msg;
    char *a;
    int i;

    for (i=1;i < argc;) {
        a = argv[i++];

        if (*a == '-') {
            do { a++; } while (*a == '-');

            if (!strcmp(a,"nodpiaware")) {
                gdi_no_dpiaware = true;
            }
            else if (!strcmp(a,"dpiaware")) {
                gdi_no_dpiaware = false;
            }
            else {
                fprintf(stderr,"Unhandled switch %s\n",a);
                return 1;
            }
        }
        else {
            fprintf(stderr,"Unhandled arg %s\n",a);
            return 1;
        }
    }

    if (sizeof(rgb24bpp_t) != 3)
        fprintf(stderr,"WARNING: uint24_t is not 3 bytes long, it is %u bytes\n",(unsigned int)sizeof(rgb24bpp_t));

    /* Please don't scale me in the name of "DPI awareness" */
    if (!gdi_no_dpiaware)
        win32_dpi_aware();

    /* Bring up DirectX */
    /* NTS: On multi-monitor setups, this will create an "emulated" object. Hardware accel won't be possible unless we enum monitors. */
    if ((hr=DirectDrawCreate(NULL,&ddraw1,NULL)) != DD_OK) {
        fprintf(stderr,"DirectDrawCreate failed, HRESULT=0x%08lx\n",hr);
        return 1;
    }
    if ((hr=ddraw1->QueryInterface(IID_IDirectDraw2,(void**)(&ddraw))) != S_OK) {
        fprintf(stderr,"Unable to query IDirectDraw2 from IDirectDraw, HR=0x%08lx\n",hr);
        return 1;
    }
    ddraw1->Release();
    ddraw1 = NULL;
    if ((hr=ddraw->SetCooperativeLevel(hwndMain,ddrawCooperativeLevel=DDSCL_NORMAL)) != DD_OK) {
        fprintf(stderr,"Unable to ask for Normal cooperative mode, HR=0x%08lx\n",hr);
        return 1;
    }

    myInstance = GetModuleHandle(NULL);

    memset(&wnd,0,sizeof(wnd));
    wnd.lpfnWndProc = WndProc;
    wnd.hInstance = myInstance;
    wnd.lpszClassName = hwndMainClass;
    wnd.hCursor = LoadCursor(NULL,IDC_ARROW);

    if (!RegisterClass(&wnd)) {
        fprintf(stderr,"RegisterClass() failed\n");
        return 1;
    }

    rect.top = 0;
    rect.left = 0;
    rect.right = 640;
    rect.bottom = 480;
    AdjustWindowRect(&rect,WS_OVERLAPPEDWINDOW,FALSE);

    hwndMain = CreateWindow(hwndMainClass,hwndMainTitle,
        hwndMainStyle=WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,CW_USEDEFAULT,
        rect.right - rect.left,rect.bottom - rect.top,
        NULL,NULL,
        myInstance,NULL);
    if (!hwndMain) {
        fprintf(stderr,"CreateWindow() failed\n");
        return 1;
    }

    if (!init_dx_primary_surface()) {
        fprintf(stderr,"Failed to init primary surface\n");
        return 1;
    }

    GetClientRect(hwndMain,&rect);
    if (!init_bitmap(rect.right,rect.bottom)) {
        fprintf(stderr,"nit_bitmap() failed for %ux%u\n",(unsigned int)rect.right,(unsigned int)rect.bottom);
        return 1;
    }
    if (lock_bitmap()) {
        render_pattern(dx_bitmap);
        unlock_bitmap();
    }

    ShowWindow(hwndMain,SW_SHOW);
    UpdateWindow(hwndMain);

    while (GetMessage(&msg,NULL,0,0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    free_dx_primary_surface();
    free_bitmap();
    if (ddraw != NULL) {
        ddraw->RestoreDisplayMode();
        ddraw->Release();
        ddraw = NULL;
    }

    if (menuDisplayModes != NULL) {
        DestroyMenu(menuDisplayModes);
        menuDisplayModes = NULL;
    }

    return 0;
}
예제 #17
0
static LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) {
    switch (uMsg) {
        case WM_CREATE:
            break;
        case WM_PAINT: {
            PAINTSTRUCT ps;
            BeginPaint(hwnd,&ps);
            EndPaint(hwnd,&ps);

            if (ddsurfacePrimary == NULL) {
                unlock_bitmap();
                free_bitmap();
                free_dx_primary_surface();
                init_dx_primary_surface();

                RECT rct;
                GetClientRect(hwndMain,&rct);

                if (!init_bitmap(rct.right,rct.bottom))
                    fprintf(stderr,"WARNING WM_RESIZE init_bitmap(%u,%u) failed\n",
                            (unsigned int)rct.right,(unsigned int)rct.bottom);

                if (lock_bitmap()) {
                    render_pattern(dx_bitmap);
                    unlock_bitmap();
                }
            }

            update_screen();
            } break;
        case WM_DISPLAYCHANGE: {
            announce_fmt = true;

            unlock_bitmap();
            free_bitmap();
            free_dx_primary_surface();
            init_dx_primary_surface();

            RECT rct;
            GetClientRect(hwndMain,&rct);

            if (!init_bitmap(rct.right,rct.bottom))
                fprintf(stderr,"WARNING WM_RESIZE init_bitmap(%u,%u) failed\n",
                        (unsigned int)rct.right,(unsigned int)rct.bottom);

            if (lock_bitmap()) {
                render_pattern(dx_bitmap);
                unlock_bitmap();
            }

            InvalidateRect(hwndMain,NULL,FALSE); // DWM compositor-based versions set WM_PAINT such that only the affected area will repaint
            } return DefWindowProc(hwnd,uMsg,wParam,lParam);
        case WM_SIZE:
            if (!init_bitmap(LOWORD(lParam),HIWORD(lParam)))
                fprintf(stderr,"WARNING WM_RESIZE init_bitmap(%u,%u) failed\n",
                    LOWORD(lParam),HIWORD(lParam));

            if (lock_bitmap()) {
                render_pattern(dx_bitmap);
                unlock_bitmap();
            }

            InvalidateRect(hwndMain,NULL,FALSE); // DWM compositor-based versions set WM_PAINT such that only the affected area will repaint
            break;
        case WM_RBUTTONUP:
            populateDisplayModes();
            if (menuDisplayModes != NULL) {
                POINT pt;

                GetCursorPos(&pt);
                TrackPopupMenu(menuDisplayModes,TPM_LEFTALIGN|TPM_TOPALIGN|TPM_RIGHTBUTTON,pt.x,pt.y,0,hwnd,NULL);
            }
            break;
        case WM_COMMAND:
            if (wParam >= 4000 && wParam < (WPARAM)(4000+displayModesCount)) {
                DDSURFACEDESC devmode = displayModes[wParam-4000];
                HRESULT hr;

                fprintf(stderr,"Setting display to %u x %u x %ubpp\n",
                    (unsigned int)devmode.dwWidth,
                    (unsigned int)devmode.dwHeight,
                    (unsigned int)devmode.ddpfPixelFormat.dwRGBBitCount);
                if ((hr=ddraw->SetDisplayMode(devmode.dwWidth,devmode.dwHeight,devmode.ddpfPixelFormat.dwRGBBitCount,devmode.dwRefreshRate,0)) != DD_OK)
                    fprintf(stderr,"Failed to set display mode HR=0x%08lx\n",hr);
                if (hr == DDERR_NOEXCLUSIVEMODE) {
                    // NTS: Windows 95/98/ME DirectX demands we enter Exclusive cooperative mode before it allows mode changes that change bit depth
                    fprintf(stderr,"Sorry, Windows demands we set the cooperative mode to Exclusive\n"); // Windows 9x/ME behavior for NORMAL cooperative mode DirectX apps
                    try_exclusive_mode();
                    if ((hr=ddraw->SetDisplayMode(devmode.dwWidth,devmode.dwHeight,devmode.ddpfPixelFormat.dwRGBBitCount,devmode.dwRefreshRate,0)) != DD_OK)
                        fprintf(stderr,"Failed to set display mode HR=0x%08lx\n",hr);
                }

                if (hr == DD_OK) {
                    if (is_exclusive_mode()) {
                        // NTS: When we're in Exclusive Fullscreen mode, Windows doesn't broadcast WM_DISPLAYCHANGE or WM_PAINT the way it normally does while we're active.
                        //      So for our display code to work we have to poke and prod the window manager and make our window fullscreen, with focus.
                        unlock_bitmap();
                        free_bitmap();
                        free_dx_primary_surface();
                        init_dx_primary_surface();

                        RECT rct;
                        GetClientRect(hwndMain,&rct);

                        if (!init_bitmap(rct.right,rct.bottom))
                            fprintf(stderr,"WARNING WM_RESIZE init_bitmap(%u,%u) failed\n",
                                    (unsigned int)rct.right,(unsigned int)rct.bottom);

                        if (lock_bitmap()) {
                            render_pattern(dx_bitmap);
                            unlock_bitmap();
                        }

                        InvalidateRect(hwndMain,NULL,FALSE); // DWM compositor-based versions set WM_PAINT such that only the affected area will repaint
                        try_exclusive_mode();
                    }
                    hasSetMode = true;
                }
            }
            else if (wParam == 5000) {
                try_exclusive_mode();
                update_screen();
            }
            else if (wParam == 5001) {
                leave_exclusive_mode();
            }
            else if (wParam == 5002) {
                leave_exclusive_mode();
                ddraw->RestoreDisplayMode();
            }
            else {
                return DefWindowProc(hwnd,uMsg,wParam,lParam);
            }
            break;
        case WM_KEYDOWN:
            switch (wParam) {
                case VK_ESCAPE:
                    PostMessage(hwnd,WM_CLOSE,0,0);
                    break;
                case VK_SPACE:
                    if ((++pattern) >= 2)
                        pattern = 0;

                    if (lock_bitmap()) {
                        render_pattern(dx_bitmap);
                        unlock_bitmap();
                    }

                    InvalidateRect(hwndMain,NULL,FALSE); // DWM compositor-based versions set WM_PAINT such that only the affected area will repaint
                    break;
            }
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        default:
            return DefWindowProc(hwnd,uMsg,wParam,lParam);
    }

    return 0;
}
예제 #18
0
void update_screen() {
    IDirectDrawSurface *dst;
    RECT dstRect;
    RECT srcRect;
    HRESULT hr;
    POINT pt;

    // NTS: dx_bitmap.is_valid() is not a valid test because base==canvas==NULL unless surface is locked
    if (ddsurfaceBMP == NULL) return;

    // NTS: We must provide a source rect, else Windows XP in 24bpp mode will conveniently choose to render the
    //      right half (where extra padding+junk exist) rather than from the left side. Provide a source rect
    //      to make it 100% clear which part of the surface we want blitted to screen.
    pt.x = pt.y = 0;
    ClientToScreen(hwndMain,&pt);
    GetClientRect(hwndMain,&dstRect);
    OffsetRect(&dstRect,pt.x,pt.y);
    srcRect.top = srcRect.left = 0;
    srcRect.right = dx_bitmap.width;
    srcRect.bottom = dx_bitmap.height;

    if (ddsurfaceGDI != NULL)
        dst = ddsurfaceGDI;
    else if (ddsurfacePrimary != NULL)
        dst = ddsurfacePrimary;
    else
        dst = NULL;

    if (dst != NULL)
        hr = dst->Blt(&dstRect,ddsurfaceBMP,&srcRect,0,NULL);
    else
        hr = DD_OK;

    if (hr == DDERR_SURFACELOST) {
        fprintf(stderr,"Whoops, the primary surface was lost.\n");
        if ((hr=dst->Restore()) != DD_OK) {
            fprintf(stderr,"Unable to restore surface hr=0x%08lx.\n",hr);
            unlock_bitmap();
            free_bitmap();
            free_dx_primary_surface();
            init_dx_primary_surface();

            RECT rct;
            GetClientRect(hwndMain,&rct);

            if (!init_bitmap(rct.right,rct.bottom))
                fprintf(stderr,"WARNING WM_RESIZE init_bitmap(%u,%u) failed\n",
                        (unsigned int)rct.right,(unsigned int)rct.bottom);

            if (lock_bitmap()) {
                render_pattern(dx_bitmap);
                unlock_bitmap();
            }

            InvalidateRect(hwndMain,NULL,FALSE); // DWM compositor-based versions set WM_PAINT such that only the affected area will repaint
        }
    }
    else if (hr != DD_OK) {
        fprintf(stderr,"DirectX blit failed, HR=0x%08lx\n",hr);
    }
}
예제 #19
0
파일: mi_mkfs.c 프로젝트: bmiro/EmoFS
/*
 * Creacio del fitxer on es te el sistema de fitxers.
 * mi_mkfs <cantidad_bloques>
 * codis de retorn:
 * 	0: correcte
 * 	-1: nombre de parametres incorrecte
 */
int main(int argc, char **argv) {
	int i = 0;
	int nombre_blocs;
	int n_inode;
	emofs_superblock sb;
	emofs_inode inode;
	/* Some fun */
	char author[][20] = { AUTHOR_B, AUTHOR_P };
	char buf[80];
	char path[MAX_PATH_LEN];
	int ascii_art; /* ASCII art, descriptor de fitxer */
	int pos;
	int read_bytes;

	emofs_block bloc_zero = block_of_zero();

	if (argc != 2) {
		nombre_blocs = DEFAULT_BLOCKS;
	} else {
		nombre_blocs = atoi(argv[1]);
	}

	bmount();

	/* Inicialitzam tot el sistema de fitxers */
	for (i = 0; i < nombre_blocs; i++) {
		bwrite(i, &bloc_zero);
	}
 
	init_superblock(nombre_blocs);
	init_bitmap();
	init_inode_array();

	/* Problema de bootstrap. Es necessita una ruta per crear un fitxer. */
	n_inode = alloc_inode(DIRECTORY_INODE);
	sbread(&sb);
	sb.root_inode = n_inode;
	sbwrite(&sb);

	/* JUST FOR FUN */
	/* Cream directori /authors */
	if (fork() == 0) {
		execl("mi_mkdir", "mi_mkdir", "/authors", (char *)0);
	} else {
		wait3(NULL, 0, NULL);
	}
	/* Cream i omplim /authors/author[i].ascii" */
	for (i = 0; i < AUTHOR_COUNT; i++) {	
		ascii_art = open(author[i], O_RDONLY, S_IRUSR);
		strcpy(path, "/authors/");	
		strcat(path, author[i]);
		emofs_create(path);
		pos = 0;
		read_bytes = 1; /* per entrar al bucle */
		while (read_bytes > 0) { /* Sortira amb el break */
			lseek(ascii_art, pos, SEEK_SET);
			read_bytes = read(ascii_art, buf, 80);
			if (!read_bytes) break;
			emofs_write(path, buf, pos, read_bytes);
			pos += read_bytes;
		}


		close(ascii_art);
	}
	/* ending fun */

    	bumount();

	return 0;
}
예제 #20
0
/* the spm allocator */
void spm_init() {
	assert(get_spm_size() % get_spm_block_size() == 0);
	init_bitmap(get_spm_size() / get_spm_block_size());
}