static pBitmapDirectory AddFile( Widget w, String file, String name, pBitmapDirectory bd) { int dummy; tBitmapEntry bitmap_entry; pBitmapDirectory entry; Window win = XRootWindowOfScreen(XtScreen(w)); if(XReadBitmapFile(XtDisplay(w), win, file, &bitmap_entry.width, &bitmap_entry.height, &bitmap_entry.bitmap, &dummy, &dummy) !=BitmapSuccess) return bd; /* Ignore invalid bitmap files */ if(!(entry = FindBitmap(name, bd))) { /* create new entry */ entry = NEW(tBitmapDirectory); entry->next = bd; bd = entry; } /* else replace existent entry! */ entry->bitmap_entry = bitmap_entry; entry->bitmap_entry.name = strdup(name); return bd; }
void CamArtProvider::EnsureBitmapLoaded(ResourceID Resource, BOOL SkipArtLoad) { UINT32 f; for (f = 0; f<CAF_CACHE_MAX; f++) { FindBitmap(Resource, (CamArtFlags)f, SkipArtLoad); // Find all the variants of the bitmap, thus ensuring a load } }
void TPack_ExtractSelected(TPack_WindowData * pData) { HWND hLB = GetDlgItem(pData->hwnd, IDC_TEXTURELIST); int nSel; BitmapEntry * pEntry; char szName[MAX_TEXTURE_NAME_LENGTH]; char szFile[MAX_PATH]; char szPath[MAX_PATH]; int nErrorCode; //---------------------------------------------- // Get current selected list box entry. // Get the geBitmap. // Write 8-bit BMP file. //---------------------------------------------- // Ouput to the current directory GetCurrentDirectory(MAX_PATH, szPath); nSel = ListBox_GetCurSel(hLB); if (nSel != LB_ERR) if (ListBox_GetText(hLB, nSel, szName) != LB_ERR) { pEntry = FindBitmap(pData, szName); if (pEntry) { // Create an output file name strcpy(szFile, szPath); strcat(szFile, "\\"); strcat(szFile, pEntry->Name); strcat(szFile, ".bmp"); nErrorCode = WriteBMP8(szFile, pEntry->Bitmap); if (nErrorCode != TPACKERROR_OK) { // Error writing this bitmap switch (nErrorCode) { case TPACKERROR_CREATEFILE: NonFatalError("Unable to create output file %s", szFile); break; case TPACKERROR_WRITE: NonFatalError("I/O error writing %s", szFile); break; case TPACKERROR_MEMORYALLOCATION: NonFatalError("Memory allocation error writing %s", szFile); break; case TPACKERROR_UNKNOWN: default: NonFatalError("UInknown error writing %s", szFile); } } } } }
int CToolBarMngr::AddBitmap(UINT BitmapID, UINT* pBtnIDs, UINT Len) { if (iBitmapCnt>=MaxDynBitmaps) return -1; if (FindBitmap(BitmapID)) return -2; //allready exists Bitmaps[iBitmapCnt] = new CToolBarBitmap(BitmapID, pBtnIDs, Len, this); iBitmapCnt++; return iBitmapCnt-1; }
/* returns the entry of the specified name */ void BDFindBitmap( String name, /* name of entry to search for */ tBitmapEntry **entry, /* return param */ pBitmapDirectory bd) { /* directory to search */ pBitmapDirectory d; if( (d = FindBitmap(name, bd)) ) { *entry = &(d->bitmap_entry); } else *entry = NULL; }
Pixmap GetBitmap(char *name) { return FindBitmap(name, &JunkWidth, &JunkHeight); }
static BOOL CALLBACK TPack_DlgProc ( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { TPack_WindowData *pData = TPack_GetWindowData (hwnd); switch (msg) { case WM_INITDIALOG : return TPack_InitializeDialog (hwnd); case WM_DESTROY : TPack_ShutdownAll (hwnd, pData); PostQuitMessage (0); break; case WM_COMMAND : { WORD wNotifyCode = HIWORD (wParam); WORD wID = LOWORD (wParam); HWND hwndCtl = (HWND)lParam; return wm_Command (hwnd, pData, wNotifyCode, wID, hwndCtl); } case MSG_DELETE_BITMAP: { BitmapEntry * Entry; Entry = FindBitmap(pData, (const char *)lParam); assert(Entry); if (Entry->Name) { free(Entry->Name); Entry->Name = NULL; } if (Entry->Bitmap) geBitmap_Destroy(&Entry->Bitmap); if (Entry->WinBitmap) DeleteObject(Entry->WinBitmap); Entry->Flags |= ENTRY_DELETED; pData->Dirty = TRUE; return 0; } case MSG_SELECT_BITMAP: { char Buff[128]; int Index; char TextureName[MAX_TEXTURE_NAME_LENGTH]; BitmapEntry * Entry; Index = SendDlgItemMessage(pData->hwnd, IDC_TEXTURELIST, LB_GETCURSEL, (WPARAM)0, (LPARAM)0); if (Index == LB_ERR) { Entry = NULL; } else { SendDlgItemMessage(pData->hwnd, IDC_TEXTURELIST, LB_GETTEXT, (WPARAM)Index, (LPARAM)&TextureName[0]); Entry = FindBitmap(pData, TextureName); assert(Entry); if (!Entry->WinBitmap) { HWND PreviewWnd; HBITMAP hbm; HDC hDC; PreviewWnd = GetDlgItem(pData->hwnd, IDC_PREVIEW); hDC = GetDC(PreviewWnd); hbm = CreateHBitmapFromgeBitmap(Entry->Bitmap, hDC); Entry->WinBitmap = hbm; ReleaseDC(PreviewWnd, hDC); } if (!Entry->WinBitmap) { NonFatalError("Memory allocation error creating bitmap"); return 0; } } InvalidateRect(GetDlgItem(hwnd, IDC_PREVIEW), NULL, TRUE); pData->SelectedEntry = Entry; if (Entry) sprintf(Buff, "%dx%d", geBitmap_Width(Entry->Bitmap), geBitmap_Height(Entry->Bitmap)); else Buff[0] = '\0'; SetWindowText(GetDlgItem(hwnd, IDC_TEXTURESIZE), Buff); return 0; } case WM_DROPFILES : { // Files dropped. HDROP hDrop; UINT FileCount; char Buff[MAX_PATH]; hDrop = (HDROP)wParam; FileCount = DragQueryFile (hDrop, 0xffffffff, Buff, sizeof (Buff)); while (FileCount--) { DragQueryFile (hDrop, FileCount, Buff, sizeof (Buff)); AddTexture(pData, NULL, Buff); } pData->Dirty = TRUE; DragFinish (hDrop); return 0; } // Initialize the pulldown // Added DJT (see revision note - 4/18/99) case WM_INITMENU: if (GetMenu(hwnd) == (HMENU)wParam) HandleInitMenu(pData, (HMENU)wParam); break; default : break; } return FALSE; }
void TPack_ExtractAll(TPack_WindowData * pData) { HWND hLB = GetDlgItem(pData->hwnd, IDC_TEXTURELIST); int nCount; int i; BitmapEntry * pEntry; char szName[MAX_TEXTURE_NAME_LENGTH]; char szFile[MAX_PATH]; char szPath[MAX_PATH]; int nErrorCode; HCURSOR hCursor; //---------------------------------------------- // Travese list box. // For each list box entry. // Get the geBitmap // Write 8-bit BMP file. //---------------------------------------------- // This may take a while, let them know something is happening // NOTE: Ideally a progress bar is needed. hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); ShowCursor(FALSE); ShowCursor(TRUE); // Ouput to the current directory GetCurrentDirectory(MAX_PATH, szPath); nCount = ListBox_GetCount(hLB); for (i = 0; i < nCount; i++) { if (ListBox_GetText(hLB, i, szName) != LB_ERR) { pEntry = FindBitmap(pData, szName); if (pEntry) { strcpy(szFile, szPath); strcat(szFile, "\\"); strcat(szFile, pEntry->Name); strcat(szFile, ".bmp"); nErrorCode = WriteBMP8(szFile, pEntry->Bitmap); if (nErrorCode != TPACKERROR_OK) { // Error writing this bitmap switch (nErrorCode) { case TPACKERROR_CREATEFILE: NonFatalError("Unable to create output file %s", szFile); break; case TPACKERROR_WRITE: NonFatalError("I/O error writing %s", szFile); break; case TPACKERROR_MEMORYALLOCATION: NonFatalError("Memory allocation error writing %s", szFile); break; case TPACKERROR_UNKNOWN: default: NonFatalError("UInknown error writing %s", szFile); } // Exit extract all loop on error break; } } } } // Restore the cursor SetCursor(hCursor); }