コード例 #1
0
ファイル: bmp256ct.cpp プロジェクト: Anonic/Meridian59
////////////////////////////////////////////////////////////
// TWallTextureontrol
// -----------------
//
void
TWallTextureControl::BuildBitmapData (const char *texname, SHORT /*remapPlayer*/)
{
   Bitmaps b;
   PDIB pdib;
   BYTE *bits;
   int size;
   
   if (DibOpenFile(texname, &b) == False)
   {
      Notify("Couldn't load texture %s", texname);
      return;
   }
   
   pdib = BitmapsGetPdib(b, 0, 0);
   if (pdib == NULL)
   {
      Notify("Missing bitmap 0 in texture %s", texname);
      return;
   }
	
   BitmapXSize = DibWidth(pdib);
   BitmapYSize = DibHeight(pdib);
   bits = DibPtr(pdib);
   
   size = BitmapXSize * BitmapYSize;
   pBitmapData = (BYTE *) GetMemory(size);
   memcpy(pBitmapData, bits, size);
   
   BitmapsFree(&b);

   // Mark used colors
   BYTE *ptrData = pBitmapData;
   for (int i = 0 ; i < size ; i++ )
   {
      pUsedColors[*ptrData] = TRUE;
      ptrData++;
   }

   return;
}
コード例 #2
0
ファイル: Imabmp.cpp プロジェクト: hackshields/antivirus
BOOL CImageBMP::ReadFile(const CString& imageFileName)
{
  if (imageFileName != "")
	 filename = imageFileName;

  if (lpbi = DibOpenFile((char *)(const char *)filename))  {
		Width =  DibWidth(lpbi);
		Height = DibHeight(lpbi);
		Depth = DibBitCount(lpbi);
		RawImage = (ImagePointerType)DibPtr(lpbi);
		EffWidth = (long)(((long)Width*Depth + 31) / 32) * 4;
		HPALETTE palette;
		if (palette = MakePalette((const BITMAPINFO FAR*)lpbi, 0))
		{
		  imagePalette = new CImagePalette;
		  imagePalette->Attach(palette);
		  DibSetUsage(lpbi, (HPALETTE) (*imagePalette), CIMAGE_COLORS);
		  ColorType = (COLORTYPE_PALETTE | COLORTYPE_COLOR);
		} 

		return TRUE;
  }
  return FALSE;
}
コード例 #3
0
ファイル: about.c プロジェクト: GarOfMeridian/Meridian59_103
/*
 * AboutInitDialog:  Handle WM_INITDIALOG messages.
 */ 
BOOL AboutInitDialog(HWND hDlg, HWND hwndFocus, LPARAM lParam) 
{
   int i,sideBuffer,xEdge,yEdge;
   POINT pt;
   HWND hwndScroll = GetDlgItem(hDlg, IDC_SCROLL);
   RECT r, rcScrollClient, rcScroll, rcDlg, rcDlgClient;
   char buffer[80];
   char format[80];

   /* Load credits from bgf file */
   if (DibOpenFile(credits_filename, &credits_b))
      credits_pdib = BitmapsGetPdibByIndex(credits_b, credits_page);
   else debug(("AboutInitDialog unable to load file %s\n", credits_filename));

   GetWindowRect(hwndScroll, &r);
   OffsetRect(&r, -r.left, -r.top);

   GetWindowRect(hDlg, &rcDlg);
   GetWindowRect(hwndScroll, &rcScroll);
   GetClientRect(hwndScroll, &rcScrollClient);
   sideBuffer = rcScroll.left - rcDlg.left;
   xEdge = (rcScroll.right-rcScroll.left) - rcScrollClient.right;
   yEdge = (rcScroll.bottom-rcScroll.top) - rcScrollClient.bottom;

   scroll_width  = DibWidth(credits_pdib);
   scroll_height = rcScrollClient.bottom;
   SetWindowPos(hwndScroll,NULL,0,0,xEdge + scroll_width,rcScroll.bottom - rcScroll.top,SWP_NOZORDER|SWP_NOMOVE);
   SetWindowPos(hDlg,NULL,0,0,xEdge + sideBuffer*2 + scroll_width,rcDlg.bottom - rcDlg.top,SWP_NOZORDER|SWP_NOMOVE);

   GetWindowRect(hDlg, &rcDlg);
   GetClientRect(hDlg, &rcDlgClient);

   // Center windows horizontally
   CenterDlgItem(hDlg, IDC_NUMBER);
   CenterDlgItem(hDlg, IDC_SPECIAL1);
   CenterDlgItem(hDlg, IDC_SPECIAL2);
   CenterDlgItem(hDlg, IDC_SCROLL);
   CenterDlgItem(hDlg, IDOK);
   
   hAboutDlg = hDlg;
   CenterWindow(hDlg, GetParent(hDlg));

   GetDlgItemText(hDlg, IDC_NUMBER, format, 80);
   sprintf(buffer, format, MAJOR_REV*100+MINOR_REV);
   SetDlgItemText(hDlg, IDC_NUMBER, buffer);

   if (config.technical)
   {
	sprintf(buffer, "Client Software Version %d:%d", MAJOR_REV, MINOR_REV);
	SetDlgItemText(hDlg, IDC_SPECIAL1, buffer);

	sprintf(buffer, "Server Host Address %s:%d",
		(LPCTSTR)config.comm.hostname, config.comm.sockport);
	SetDlgItemText(hDlg, IDC_SPECIAL2, buffer);
   }

   GetWindowRect(GetDlgItem(hDlg,IDC_SPECIAL2),&r);
   pt.x = r.left + (r.right-r.left)/2 - DUDE_AREA_WIDTH/2;
   pt.y = r.bottom + 10;
   ScreenToClient(hDlg,&pt);

   scroll_y = 0;
   dude_x = pt.x;
   dude_y = pt.y;

   gbits_width  = max(scroll_width, DUDE_AREA_WIDTH);
   gbits_height = max(scroll_height, DUDE_MAX_HEIGHT);

   gDC = CreateMemBitmap(gbits_width, gbits_height, &gOldBitmap, &gBits);
   if (gDC == 0)
      debug(("AboutInitDialog couldn't create DC!\n"));

   timer_id = SetTimer(hDlg, TIMER_ABOUT, ABOUT_INTERVAL, NULL);

   if (state == STATE_GAME)
   {
      // Set up animated characters
      for (i=0; i < NUM_DUDES; i++)
      {
	 object_node *obj;
	 
	 obj = dudes[i].obj = ObjectGetBlank();	
	 obj->icon_res = ABOUT_RSC;
	 obj->animate->animation = ANIMATE_NONE;
	 
	 if (i == 0)
	 {
	    dudes[i].angle = 3 * NUMDEGREES / 4;
	    dudes[i].x = DUDE_X1;
	 }
	 else 
	 {
	    dudes[i].angle = NUMDEGREES / 4;
	    dudes[i].x = DUDE_X2;
	 }
      }
   }
   
   CenterWindow(hDlg, GetParent(hDlg));
   return TRUE;
}
コード例 #4
0
ファイル: intro.c プロジェクト: GarOfMeridian/Meridian59_103
/*
 * IntroShowSplash:  Display splash screen.
 */
void IntroShowSplash(void)
{
   RECT rect;
   BYTE *gTitleBits;
   int i;
   Bitmaps b;
   PDIB pdib;

   if (cinfo->config->quickstart)
   {
      OfflineConnect();
      return;
   }
   if (showing_splash)
     return;
   showing_splash = True;

   IntroFreeLogo();
   hwndDialButton = CreateWindow("button", NULL, 
		WS_CHILD | WS_VISIBLE,
		0, 0, 0, 0, cinfo->hMain, (HMENU) IDC_DIALBUTTON,
		hInst, NULL);
   SetWindowText(hwndDialButton, GetString(hInst, IDS_INTRO));

   /* Subclass button */
   lpfnDefButtonProc = SubclassWindow(hwndDialButton, MainButtonProc);

   /* Get bits of bitmap from bgf file */   
   if (DibOpenFile(splash_filename, &b))
   {
      pdib = BitmapsGetPdibByIndex(b, 0);

      /* Get bitmap's size */
      bm_width  = DibWidth(pdib);
      bm_height = DibHeight(pdib);

      /* Create bitmap */
      hTitleDC = CreateMemBitmap(bm_width, bm_height, &hOldTitleBitmap, &gTitleBits);
      if (hTitleDC == NULL)
      {
	 debug(("IntroShowSplash couldn't create bitmap!\n"));
	 BitmapsFree(&b);
	 return;
      }
      
      /* Copy bits into bitmap */
      for (i=0; i < bm_height; i++)
	 memcpy(gTitleBits + i * DIBWIDTH(bm_width), DibPtr(pdib) + i * bm_width, bm_width);

      BitmapsFree(&b);

   }
   else 
   {
      hTitleDC = NULL;
      bm_width = BUTTON_XSIZE;
   }

   button_width = bm_width;
   button_height = BUTTON_YSIZE;

   /* Simulate resize to get positions right */
   GetClientRect(cinfo->hMain, &rect);
   EventResize(rect.right, rect.bottom, NULL);

   SetFocus(hwndDialButton);

   timer_id = SetTimer(NULL, 0, MUSIC_DELAY, PlayMusicProc);
}
コード例 #5
0
ファイル: makebgf.c プロジェクト: rynet/Meridian59
/*
 * ReadCommandLine:  Go through bitmap description list on command line,
 *   and fill in info structure.  This includes loading the bitmaps in.
 *   "shrink" gives the shrink factor, already read in from the command line.
 */
void ReadCommandLine(int argc, char **argv, Options *options)
{
    int i, j, arg = 0;  // Argument we're currently looking at

    // First, load bitmaps
    b.num_bitmaps = atoi(argv[0]);

    if (b.num_bitmaps < 1)
        Error("Number of bitmaps must be at least 1");
    arg++;

    b.bitmaps = (PDIB *) SafeMalloc(b.num_bitmaps * sizeof(PDIB));
    b.offsets = (POINT *) SafeMalloc(b.num_bitmaps * sizeof(POINT));
    b.hotspots = (Hotspots *) SafeMalloc(b.num_bitmaps * sizeof(Hotspots));
    for (i=0; i < b.num_bitmaps; i++)
    {
        if (arg >= argc)
            Error("Not enough bitmap files given");

        b.bitmaps[i] = DibOpenFile(argv[arg]);
        if (b.bitmaps[i] == NULL)
            Error("Unable to load bitmap file %s", argv[arg]);

        arg++;

        // Read offsets, if present
        b.offsets[i].x = 0;
        b.offsets[i].y = 0;
        if (arg <= argc - 2 && argv[arg][0] == '[')
        {
            ReadPoint(argv[arg] + 1, argv[arg+1], &b.offsets[i]);
            arg += 2;  // Skip read arguments
        }

        // Read hotspots, if present
        b.hotspots[i].num_hotspots = 0;

        if (arg <= argc - 1 && argv[arg][0] == ':')
        {
            b.hotspots[i].num_hotspots = atoi(argv[arg] + 1);
            arg++;

            b.hotspots[i].positions =
                (POINT *) SafeMalloc(b.hotspots[i].num_hotspots * sizeof(POINT));
            b.hotspots[i].numbers = (char *) SafeMalloc(b.hotspots[i].num_hotspots * sizeof(BYTE));
            for (j=0; j < b.hotspots[i].num_hotspots; j++)
            {
                if (arg > argc - 3)
                    Error("Not enough hotspots for bitmap #%d", i);

                b.hotspots[i].numbers[j] = atoi(argv[arg]);
                if (b.hotspots[i].numbers[j] == 0)
                    Error("Hotspot #%d for bitmap #%d must not be 0", j + 1, i + 1);
                arg++;

                ReadPoint(argv[arg] + 1, argv[arg+1], &b.hotspots[i].positions[j]);
                arg += 2;  // Skip read arguments
            }

        }
    }

    // Next, store indices into structure
    if (arg >= argc)
        Error("Missing number of index groups");
    b.num_groups = atoi(argv[arg]);
    b.groups = (Group *) SafeMalloc(b.num_groups * sizeof(Group));
    arg++;

    for (i=0; i < b.num_groups; i++)
    {
        Group *g = &b.groups[i];
        if (arg >= argc)
            Error("Missing number of indices in index group %d", i+1);

        g->num_indices = atoi(argv[arg]);
        if (g->num_indices < 1)
            Error("Number of indices in a group must be at least 1");
        arg++;

        g->indices = (int *) SafeMalloc(g->num_indices * sizeof(int));

        // Read in the indices
        for (j=0; j < g->num_indices; j++)
        {
            if (arg >= argc)
                Error("Not enough indices in group %d", i+1);

            g->indices[j] = atoi(argv[arg]) - 1;  // Start counting from 0 in file
            if (g->indices[j] < -1)
                Error("Index must be at least 0");
            arg++;
        }
    }

    if (arg != argc)
        printf("Extra command line arguments ignored\n");
}