Esempio n. 1
0
Bool
apc_prn_begin_doc( Handle self, const char* docName)
{
   LPPRINTER_INFO_2 ppi = &sys s. prn. ppi;
   DOCINFO doc;
   doc. cbSize = sizeof( DOCINFO);
   doc. lpszDocName = docName;
   doc. lpszOutput = nil;
   doc. lpszDatatype = nil;
   doc. fwType = 0;

   objCheck false;
   if ( !( sys ps = CreateDC( ppi-> pDriverName, ppi-> pPrinterName, ppi-> pPortName, ppi-> pDevMode)))
      apiErrRet;

   if ( StartDoc( sys ps, &doc) <= 0) {
      apiPrnErr;
      DeleteDC( sys ps);
      sys ps = nil;
      return false;
   }
   if ( StartPage( sys ps) <= 0) {
      apiPrnErr;
      DeleteDC( sys ps);
      sys ps = nil;
      return false;
   }

   hwnd_enter_paint( self);
   if (( sys pal = palette_create( self))) {
      SelectPalette( sys ps, sys pal, 0);
      RealizePalette( sys ps);
   }
   return true;
}
Esempio n. 2
0
/*
    Calculate a RGB palette out of VIC/VIC-II/TED colors (in ycbcr format),
    apply saturation, brightness, contrast, tint and gamma settings.

    this palette will be used for screenshots and by renderers if CRT emulation
    is disabled.
*/
static palette_t *video_calc_palette(struct video_canvas_s *canvas, const video_ycbcr_palette_t *p)
{
    palette_t *prgb;
    unsigned int i;
    float sat, bri, con, gam, tin;
    video_resources_t *video_resources = &(canvas->videoconfig->video_resources);

    DBG(("video_calc_palette"));

    sat = ((float)(video_resources->color_saturation)) / 1000.0f;
    bri = ((float)(video_resources->color_brightness - 1000)) * (128.0f / 1000.0f);
    con = ((float)(video_resources->color_contrast)) / 1000.0f;
    gam = video_get_gamma(video_resources);
    tin = (((float)(video_resources->color_tint)) / (2000.0f / 50.0f)) - 25.0f;

    /* create RGB palette with the base colors of the video chip */
    prgb = palette_create(p->num_entries, NULL);
    if (prgb == NULL) {
        return NULL;
    }

    for (i = 0; i < p->num_entries; i++) {
        video_convert_ycbcr_to_rgb(&p->entries[i], sat, bri, con, gam, tin,
                                   &prgb->entries[i]);
    }

    return prgb;
}
Esempio n. 3
0
/*
    Calculate a RGB palette out of VIC/VIC-II/TED colors (in ycbcr format),
    apply saturation, brightness, contrast, tint and gamma settings.

    this palette will be used for screenshots and by renderers if CRT emulation
    is disabled.
*/
static palette_t *video_calc_palette(struct video_canvas_s *canvas, const video_ycbcr_palette_t *p, int video)
{
    palette_t *prgb;
    unsigned int i;
    float sat, bri, con, gam, tin;
    video_resources_t *video_resources = &(canvas->videoconfig->video_resources);

    DBG(("video_calc_palette"));

    sat = ((float)(video_resources->color_saturation)) / 1000.0f;
    bri = ((float)(video_resources->color_brightness - 1000)) * (128.0f / 1000.0f);
    con = ((float)(video_resources->color_contrast)) / 1000.0f;
    gam = video_get_gamma(video_resources, video);
    tin = (((float)(video_resources->color_tint)) / (2000.0f / 50.0f)) - 25.0f;

    /* create RGB palette with the base colors of the video chip */
    prgb = palette_create(p->num_entries, NULL);
    if (prgb == NULL) {
        return NULL;
    }

    DBG((" sat:%d bri:%d con:%d gam:%d tin:%d", (int)sat, (int)bri, (int)con, (int)gam, (int)tin));

    for (i = 0; i < p->num_entries; i++) {
        video_convert_renderer_to_rgb_gamma(&p->entries[i], sat, bri, con, gam, tin, &prgb->entries[i], video);
        DBG((" %2d: Y:%4d Cb:%4d Cr:%4d  R:%3d G:%3d B:%3d", i,
            (int)p->entries[i].y, (int)p->entries[i].cb, (int)p->entries[i].cr,
            (int)prgb->entries[i].red, (int)prgb->entries[i].green, (int)prgb->entries[i].blue));
    }

    return prgb;
}
Esempio n. 4
0
int drv_mps803_init(void)
{
    static const char *color_names[2] =
    {
        "Black", "White"
    };

    drv803_log = log_open("MPS-803");

    init_charset(charset, "mps803");

    palette = palette_create(2, color_names);

    if (palette == NULL) {
        return -1;
    }

    if (palette_load("mps803" FSDEV_EXT_SEP_STR "vpl", palette) < 0) {
        log_error(drv803_log, "Cannot load palette file `%s'.",
                  "mps803" FSDEV_EXT_SEP_STR "vpl");
        return -1;
    }

    return 0;
}
Esempio n. 5
0
int palette_load(const char *file_name, palette_t *palette_return)
{
    palette_t *tmp_palette;
    char *complete_path;
    FILE *f;
    int rc;

    f = sysfile_open(file_name, &complete_path, MODE_READ_TEXT);

    if (f == NULL) {
        /* Try to add the extension.  */
        char *tmp = lib_stralloc(file_name);

        util_add_extension(&tmp, "vpl");
        f = sysfile_open(tmp, &complete_path, MODE_READ_TEXT);
        lib_free(tmp);

        if (f == NULL)
            return -1;
    }

    log_message(palette_log, "Loading palette `%s'.", complete_path);
    lib_free(complete_path);

    tmp_palette = palette_create(palette_return->num_entries, NULL);

    rc = palette_load_core(f, file_name, tmp_palette, palette_return);

    fclose(f);
    palette_free(tmp_palette);

    return rc;
}
Esempio n. 6
0
Bool
apc_dbm_create( Handle self, Bool monochrome)
{
   Bool palc = 0;

   objCheck false;
   apcErrClear;
   apt_set( aptBitmap);
   apt_set( aptDeviceBitmap);
   apt_set( aptCompatiblePS);

   if ( !( sys ps = CreateCompatibleDC( 0))) apiErrRet;
   sys lastSize. x = var w;
   sys lastSize. y = var h;

   if ( monochrome)
      sys bm = CreateBitmap( var w, var h, 1, 1, nil);
   else {
      HDC dc;
      if (!( dc = dc_alloc())) {
         DeleteDC( sys ps);
         return false;
      }
      if (( sys pal = palette_create( self))) {
         sys stockPalette = SelectPalette( sys ps, sys pal, 1);
         RealizePalette( sys ps);
         palc = 1;
      }
      sys bm = CreateCompatibleBitmap( dc, var w, var h);
      if ( guts. displayBMInfo. bmiHeader. biBitCount == 8)
         apt_clear( aptCompatiblePS);
   }

   if ( !sys bm) {
      apiErr;
      if ( !monochrome) dc_free();
      if ( palc) {
         SelectPalette( sys ps, sys stockPalette, 1);
         DeleteObject( sys stockPalette);
         sys stockPalette = nil;
      }
      DeleteDC( sys ps);
      return false;
   }
   if ( !monochrome) dc_free();

   sys stockBM = SelectObject( sys ps, sys bm);

   hwnd_enter_paint( self);
   if ( monochrome) sys bpp = 1;

   hash_store( imageMan, &self, sizeof( self), (void*)self);
   return true;
}
Esempio n. 7
0
void menubar_create(menubar_t *m)
{
	memset(m,0,sizeof(menubar_t));

	m->info.type = G_MENUBAR;
	m->info.x = 0;
	m->info.y = 0;
	m->info.w = 256;
	m->info.h = 14;
	m->info.draw = (drawfunc_t)menubar_draw;
	m->info.event = (eventfunc_t)menubar_event;

	//this needs to be configurable, passed thru in a struct
	menu_create(&m->menus[0],"\x1",4,recentitems);
	menu_create(&m->menus[1],"Game",m->menus[0].info.x + m->menus[0].info.w + 4,gameitems);
	menu_create(&m->menus[2],"Config",m->menus[1].info.x + m->menus[1].info.w + 4,configitems);
	menu_create(&m->menus[3],"Cheat",m->menus[2].info.x + m->menus[2].info.w + 4,miscitems);
	menu_create(&m->menus[4],"Debug",m->menus[3].info.x + m->menus[3].info.w + 4,debugitems);
	button_create(&m->buttons[0],"x",(256 - 9) - 3,3,click_quit);
	button_create(&m->buttons[1],"\x9",(256 - 33) - 1,3,click_minimize);
	button_create(&m->buttons[2],"\x8",(256 - 21) - 3,3,click_togglefullscreen);
	load_create(&m->load);
	video_create(&m->video);
	input_create(&m->input);
	gui_input_create(&m->guiinput);
	sound_create(&m->sound);
	devices_create(&m->devices);
	palette_create(&m->palette);
	options_create(&m->options);
	mappers_create(&m->mappers);
	paths_create(&m->paths);
	supported_mappers_create(&m->supported_mappers);
	rom_info_create(&m->rom_info);
	tracer_create(&m->tracer);
	memory_viewer_create(&m->memory_viewer);
	nt_create(&m->nametable_viewer);
	pt_create(&m->patterntable_viewer);
	about_create(&m->about);

	m->menus[0].click = click_recent;
	m->menus[1].click = click_game;
	m->menus[2].click = click_config;
	m->menus[3].click = click_debug;
	m->menus[4].click = click_misc;
	m->menus[0].user = m;
	m->menus[1].user = m;
	m->menus[2].user = m;
	m->menus[3].user = m;
	m->menus[4].user = m;

	//'hack' to update the 'freeze data' caption
	click_freezedata();
	click_freezedata();
}
Esempio n. 8
0
Bool
apc_prn_begin_paint_info( Handle self)
{
   LPPRINTER_INFO_2 ppi = &sys s. prn. ppi;

   objCheck false;
   if ( !( sys ps = CreateDC( ppi-> pDriverName, ppi-> pPrinterName, ppi-> pPortName, ppi-> pDevMode)))
      apiErrRet;

   hwnd_enter_paint( self);
   sys pal = palette_create( self);
   return true;
}
Esempio n. 9
0
extern void bitmap_write(struct bitmap *bitmap)
{
	if (!output_path && is_tty_stdout())
		message_fatal("Data cannot be written to a terminal");

	FILE *fp = output_path ? fopen(output_path, "wb") : stdout;

	if (fp == NULL)
		message_fatal("Unable to open file for writing");

	png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
					NULL, NULL, NULL);

	if (png_ptr == NULL)
		message_fatal("Unable to create png struct");

	png_infop info_ptr = png_create_info_struct(png_ptr);

	if (info_ptr == NULL)
		message_fatal("Unable to create png info struct");

	if (setjmp(png_jmpbuf(png_ptr))) {
		fclose(fp);
		png_destroy_write_struct(&png_ptr, &info_ptr);
		message_fatal("Error writing png file");
	}

	png_init_io(png_ptr, fp);

	png_set_IHDR(png_ptr, info_ptr, bitmap->width, bitmap->height, 8,
		PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE,
		PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);

	png_color *palette = palette_create();
	png_set_PLTE(png_ptr, info_ptr, palette, 256);

	png_bytep row_pointers[bitmap->height];

	for (unsigned y = 0; y < bitmap->height; y++)
		row_pointers[y] = bitmap->data + bitmap->width * y;

	png_write_info(png_ptr, info_ptr);
	png_write_image(png_ptr, row_pointers);
	png_write_end(png_ptr, info_ptr);

	palette_release(palette);
	png_destroy_write_struct(&png_ptr, &info_ptr);
	fclose(fp);
}
Esempio n. 10
0
/* Load RGB palette.  */
static palette_t *video_load_palette(const video_cbm_palette_t *p,
                                     const char *name)
{
    palette_t *palette;

    palette = palette_create(p->num_entries, NULL);

    if (palette == NULL) {
        return NULL;
    }

    if (!video_disabled_mode && palette_load(name, palette) < 0) {
        /* log_message(vicii.log, "Cannot load palette file `%s'.", name); */
        return NULL;
    }

    return palette;
}