Ignore:
Timestamp:
Feb 10, 2000, 1:36:11 AM (26 years ago)
Author:
sandervl
Message:

CreateDIBSection enhancement + CreateICA/W bugfix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/dibsect.cpp

    r2706 r2718  
    1 /* $Id: dibsect.cpp,v 1.16 2000-02-09 23:34:30 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.17 2000-02-10 00:36:10 sandervl Exp $ */
    22
    33/*
     
    88 *
    99 * Project Odin Software License can be found in LICENSE.TXT
     10 *
     11 * NOTE:
     12 * This is not a complete solution for CreateDIBSection, but enough for Quake 2!
    1013 *
    1114 */
     
    2124#include <vmutex.h>
    2225#include <winconst.h>
    23 
     26#include <win32wnd.h>
     27#include "oslibgpi.h"
     28
     29//Win32 apis used:
    2430HWND WIN32API WindowFromDC(HDC hdc);
    25 HWND Win32ToOS2Handle(HWND hwnd);
    26 
    27 BOOL    APIENTRY _GpiEnableYInversion (HPS hps, LONG lHeight);
    28 
    29 inline BOOL APIENTRY GpiEnableYInversion (HPS hps, LONG lHeight)
    30 {
    31  BOOL yyrc;
    32  USHORT sel = RestoreOS2FS();
    33 
    34     yyrc = _GpiEnableYInversion(hps, lHeight);
    35     SetFS(sel);
    36 
    37     return yyrc;
    38 }
     31BOOL   WINAPI UnmapViewOfFile(LPVOID addr);
     32LPVOID WINAPI MapViewOfFile(HANDLE mapping, DWORD access, DWORD offset_high,
     33                            DWORD offset_low, DWORD count);
    3934
    4035static VMutex dibMutex;
    4136
    42 //NOTE:
    43 //This is not a complete solution for CreateDIBSection, but enough for Quake 2!
    44 //******************************************************************************
    45 //******************************************************************************
    46 DIBSection::DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD handle, int fFlip)
     37//******************************************************************************
     38//******************************************************************************
     39DIBSection::DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip)
    4740                : bmpBits(NULL), pOS2bmp(NULL), next(NULL)
    4841{
     
    8275   }
    8376
    84    bmpBits    = (char *)malloc(bmpsize*pbmi->biHeight);
     77   this->hSection = hSection;
     78   if(hSection) {
     79        bmpBits = (char *)MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS_W, 0, dwOffset, bmpsize*pbmi->biHeight);
     80        if(!bmpBits) {
     81                dprintf(("Dibsection: mapViewOfFile %x failed!", hSection));
     82                DebugInt3();
     83        }
     84   }
     85   if(!bmpBits) {
     86        DosAllocMem((PPVOID)&bmpBits, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
     87   }
    8588   memset(bmpBits, 0, bmpsize*pbmi->biHeight);
    8689
    87    pOS2bmp    = (BITMAPINFO2 *)malloc(os2bmpsize);
     90   pOS2bmp = (BITMAPINFO2 *)malloc(os2bmpsize);
    8891
    8992   memset(pOS2bmp, /* set header + palette entries to zero */
     
    164167{
    165168   dprintf(("Delete DIBSection %x", handle));
     169
     170   if(hSection) {
     171        UnmapViewOfFile(bmpBits);
     172   }
     173   else
    166174   if(bmpBits)
    167         free(bmpBits);
     175        DosFreeMem(bmpBits);
     176
    168177   if(pOS2bmp)
    169178        free(pOS2bmp);
Note: See TracChangeset for help on using the changeset viewer.