ReactOS  0.4.15-dev-3203-gacde1e0
dib.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DIB_PAL_BRUSHHACK   3
 

Functions

INT FASTCALL DIB_BitmapInfoSize (const BITMAPINFO *info, WORD coloruse)
 
HBITMAP APIENTRY DIB_CreateDIBSection (PDC dc, CONST BITMAPINFO *bmi, UINT usage, LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch)
 
int FASTCALL DIB_GetBitmapInfo (const BITMAPINFOHEADER *header, LONG *width, LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size)
 
INT APIENTRY DIB_GetDIBImageBytes (INT width, INT height, INT depth)
 
HPALETTE FASTCALL DIB_MapPaletteColors (PPALETTE ppal, CONST BITMAPINFO *lpbmi)
 
HPALETTE FASTCALL BuildDIBPalette (CONST BITMAPINFO *bmi)
 
BITMAPINFO *FASTCALL DIB_ConvertBitmapInfo (CONST BITMAPINFO *bmi, DWORD Usage)
 
VOID FASTCALL DIB_FreeConvertedBitmapInfo (BITMAPINFO *converted, BITMAPINFO *orig, DWORD Usage)
 
INT APIENTRY GreGetDIBitsInternal (HDC hDC, HBITMAP hBitmap, UINT StartScan, UINT ScanLines, LPBYTE Bits, LPBITMAPINFO Info, UINT Usage, UINT MaxBits, UINT MaxInfo)
 
HBITMAP NTAPI GreCreateDIBitmapFromPackedDIB (_In_reads_(cjPackedDIB) PVOID pvPackedDIB, _In_ UINT cjPackedDIB, _In_ ULONG uUsage)
 

Macro Definition Documentation

◆ DIB_PAL_BRUSHHACK

#define DIB_PAL_BRUSHHACK   3

Definition at line 36 of file dib.h.

Function Documentation

◆ BuildDIBPalette()

HPALETTE FASTCALL BuildDIBPalette ( CONST BITMAPINFO bmi)

◆ DIB_BitmapInfoSize()

INT FASTCALL DIB_BitmapInfoSize ( const BITMAPINFO info,
WORD  coloruse 
)

Definition at line 2134 of file dibobj.c.

2135 {
2136  unsigned int colors, size, masks = 0;
2137  unsigned int colorsize;
2138 
2139  colorsize = (coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) :
2140  (coloruse == DIB_PAL_INDICES) ? 0 :
2141  sizeof(WORD);
2142 
2143  if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
2144  {
2145  const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info;
2146  colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0;
2147  return sizeof(BITMAPCOREHEADER) + colors * colorsize;
2148  }
2149  else /* Assume BITMAPINFOHEADER */
2150  {
2151  colors = info->bmiHeader.biClrUsed;
2152  if (colors > 256) colors = 256;
2153  if (!colors && (info->bmiHeader.biBitCount <= 8))
2154  colors = 1 << info->bmiHeader.biBitCount;
2155  if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3;
2156  size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) );
2157  return size + colors * colorsize;
2158  }
2159 }
#define max(a, b)
Definition: svc.c:63
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define BI_BITFIELDS
Definition: mmreg.h:507
GLsizeiptr size
Definition: glext.h:5919
ULONG RGBQUAD
Definition: precomp.h:50
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DIB_PAL_INDICES
#define DIB_RGB_COLORS
Definition: wingdi.h:366
static const BYTE masks[8]
Definition: dib.c:2760

Referenced by _Success_(), GreCreateDIBitmapFromPackedDIB(), and NtGdiCreateDIBSection().

◆ DIB_ConvertBitmapInfo()

BITMAPINFO* FASTCALL DIB_ConvertBitmapInfo ( CONST BITMAPINFO bmi,
DWORD  Usage 
)

Definition at line 2207 of file dibobj.c.

2208 {
2210  BITMAPINFO* pNewBmi ;
2211  UINT numColors = 0, ColorsSize = 0;
2212 
2213  if(pbmi->bmiHeader.biSize >= sizeof(BITMAPINFOHEADER)) return (BITMAPINFO*)pbmi;
2214  if(pbmi->bmiHeader.biSize != sizeof(BITMAPCOREHEADER)) return NULL;
2215 
2216  if(pbmci->bmciHeader.bcBitCount <= 8)
2217  {
2218  numColors = 1 << pbmci->bmciHeader.bcBitCount;
2219  if(Usage == DIB_PAL_COLORS)
2220  {
2221  ColorsSize = numColors * sizeof(WORD);
2222  }
2223  else
2224  {
2225  ColorsSize = numColors * sizeof(RGBQUAD);
2226  }
2227  }
2228  else if (Usage == DIB_PAL_COLORS)
2229  {
2230  /* Invalid at high-res */
2231  return NULL;
2232  }
2233 
2234  pNewBmi = ExAllocatePoolWithTag(PagedPool, sizeof(BITMAPINFOHEADER) + ColorsSize, TAG_DIB);
2235  if(!pNewBmi) return NULL;
2236 
2237  RtlZeroMemory(pNewBmi, sizeof(BITMAPINFOHEADER) + ColorsSize);
2238 
2239  pNewBmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
2240  pNewBmi->bmiHeader.biBitCount = pbmci->bmciHeader.bcBitCount;
2241  pNewBmi->bmiHeader.biWidth = pbmci->bmciHeader.bcWidth;
2242  pNewBmi->bmiHeader.biHeight = pbmci->bmciHeader.bcHeight;
2243  pNewBmi->bmiHeader.biPlanes = pbmci->bmciHeader.bcPlanes;
2244  pNewBmi->bmiHeader.biCompression = BI_RGB ;
2246  pNewBmi->bmiHeader.biHeight,
2247  pNewBmi->bmiHeader.biBitCount);
2248  pNewBmi->bmiHeader.biClrUsed = numColors;
2249 
2250  if(Usage == DIB_PAL_COLORS)
2251  {
2252  RtlCopyMemory(pNewBmi->bmiColors, pbmci->bmciColors, ColorsSize);
2253  }
2254  else
2255  {
2256  UINT i;
2257  for(i=0; i<numColors; i++)
2258  {
2259  pNewBmi->bmiColors[i].rgbRed = pbmci->bmciColors[i].rgbtRed;
2260  pNewBmi->bmiColors[i].rgbGreen = pbmci->bmciColors[i].rgbtGreen;
2261  pNewBmi->bmiColors[i].rgbBlue = pbmci->bmciColors[i].rgbtBlue;
2262  }
2263  }
2264 
2265  return pNewBmi ;
2266 }
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
#define DIB_PAL_COLORS
Definition: wingdi.h:365
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
DWORD biCompression
Definition: amvideo.idl:35
ULONG RGBQUAD
Definition: precomp.h:50
RGBQUAD bmiColors[1]
Definition: wingdi.h:1476
unsigned short WORD
Definition: ntddk_ex.h:93
DWORD biSizeImage
Definition: amvideo.idl:36
INT APIENTRY DIB_GetDIBImageBytes(INT width, INT height, INT depth)
Definition: dibobj.c:2122
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define BI_RGB
Definition: precomp.h:47
#define CONST
Definition: pedump.c:81
#define TAG_DIB
Definition: tags.h:17

Referenced by GreGetDIBitsInternal(), IntSynthesizeBitmap(), and UserLoadImage().

◆ DIB_CreateDIBSection()

HBITMAP APIENTRY DIB_CreateDIBSection ( PDC  dc,
CONST BITMAPINFO bmi,
UINT  usage,
LPVOID bits,
HANDLE  section,
DWORD  offset,
DWORD  ovr_pitch 
)

Definition at line 1880 of file dibobj.c.

1888 {
1889  HBITMAP res = 0;
1890  SURFACE *bmp = NULL;
1891  void *mapBits = NULL;
1892  PPALETTE ppalDIB = NULL;
1893 
1894  // Fill BITMAP32 structure with DIB data
1895  CONST BITMAPINFOHEADER *bi = &bmi->bmiHeader;
1896  INT effHeight;
1897  ULONG totalSize;
1898  BITMAP bm;
1899  //SIZEL Size;
1900  HANDLE hSecure;
1901 
1902  DPRINT("format (%ld,%ld), planes %u, bpp %u, size %lu, colors %lu (%s)\n",
1903  bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
1904  bi->biSizeImage, bi->biClrUsed, usage == DIB_PAL_COLORS? "PAL" : "RGB");
1905 
1906  /* CreateDIBSection should fail for compressed formats */
1907  if (bi->biCompression == BI_RLE4 || bi->biCompression == BI_RLE8)
1908  {
1909  DPRINT1("no compressed format allowed\n");
1910  return (HBITMAP)NULL;
1911  }
1912 
1913  effHeight = bi->biHeight >= 0 ? bi->biHeight : -bi->biHeight;
1914  bm.bmType = 0;
1915  bm.bmWidth = bi->biWidth;
1916  bm.bmHeight = effHeight;
1917  bm.bmWidthBytes = ovr_pitch ? ovr_pitch : WIDTH_BYTES_ALIGN32(bm.bmWidth, bi->biBitCount);
1918 
1919  bm.bmPlanes = bi->biPlanes;
1920  bm.bmBitsPixel = bi->biBitCount;
1921  bm.bmBits = NULL;
1922 
1923  // Get storage location for DIB bits. Only use biSizeImage if it's valid and
1924  // we're dealing with a compressed bitmap. Otherwise, use width * height.
1925  totalSize = (bi->biSizeImage && (bi->biCompression != BI_RGB) && (bi->biCompression != BI_BITFIELDS))
1926  ? bi->biSizeImage : (ULONG)(bm.bmWidthBytes * effHeight);
1927 
1928  if (section)
1929  {
1931  NTSTATUS Status;
1932  DWORD mapOffset;
1934  SIZE_T mapSize;
1935 
1937  &Sbi,
1938  sizeof Sbi,
1939  0);
1940  if (!NT_SUCCESS(Status))
1941  {
1942  DPRINT1("ZwQuerySystemInformation failed (0x%lx)\n", Status);
1943  return NULL;
1944  }
1945 
1946  mapOffset = offset - (offset % Sbi.AllocationGranularity);
1947  mapSize = totalSize + (offset - mapOffset);
1948 
1949  SectionOffset.LowPart = mapOffset;
1950  SectionOffset.HighPart = 0;
1951 
1952  Status = ZwMapViewOfSection(section,
1953  NtCurrentProcess(),
1954  &mapBits,
1955  0,
1956  0,
1957  &SectionOffset,
1958  &mapSize,
1959  ViewShare,
1960  0,
1961  PAGE_READWRITE);
1962  if (!NT_SUCCESS(Status))
1963  {
1964  DPRINT1("ZwMapViewOfSection failed (0x%lx)\n", Status);
1966  return NULL;
1967  }
1968 
1969  if (mapBits) bm.bmBits = (char *)mapBits + (offset - mapOffset);
1970  }
1971  else if (ovr_pitch && offset)
1972  bm.bmBits = UlongToPtr(offset);
1973  else
1974  {
1975  offset = 0;
1976  bm.bmBits = EngAllocUserMem(totalSize, 0);
1977  if(!bm.bmBits)
1978  {
1979  DPRINT1("Failed to allocate memory\n");
1980  goto cleanup;
1981  }
1982  }
1983 
1984 // hSecure = MmSecureVirtualMemory(bm.bmBits, totalSize, PAGE_READWRITE);
1985  hSecure = (HANDLE)0x1; // HACK OF UNIMPLEMENTED KERNEL STUFF !!!!
1986 
1987 
1988  // Create Device Dependent Bitmap and add DIB pointer
1989  //Size.cx = bm.bmWidth;
1990  //Size.cy = abs(bm.bmHeight);
1991  res = GreCreateBitmapEx(bm.bmWidth,
1992  abs(bm.bmHeight),
1993  bm.bmWidthBytes,
1994  BitmapFormat(bi->biBitCount * bi->biPlanes, bi->biCompression),
1996  ((bi->biHeight < 0) ? BMF_TOPDOWN : 0),
1997  totalSize,
1998  bm.bmBits,
1999  0);
2000  if (!res)
2001  {
2002  DPRINT1("GreCreateBitmapEx failed\n");
2004  goto cleanup;
2005  }
2006  bmp = SURFACE_ShareLockSurface(res); // HACK
2007  if (NULL == bmp)
2008  {
2009  DPRINT1("SURFACE_LockSurface failed\n");
2011  goto cleanup;
2012  }
2013 
2014  /* WINE NOTE: WINE makes use of a colormap, which is a color translation
2015  table between the DIB and the X physical device. Obviously,
2016  this is left out of the ReactOS implementation. Instead,
2017  we call NtGdiSetDIBColorTable. */
2018  bmp->hDIBSection = section;
2019  bmp->hSecure = hSecure;
2020  bmp->dwOffset = offset;
2021  bmp->flags = API_BITMAP;
2022  bmp->biClrImportant = bi->biClrImportant;
2023 
2024  /* Create a palette for the DIB */
2025  ppalDIB = CreateDIBPalette(bmi, dc, usage);
2026 
2027  // Clean up in case of errors
2028 cleanup:
2029  if (!res || !bmp || !bm.bmBits || !ppalDIB)
2030  {
2031  DPRINT("Got an error res=%p, bmp=%p, bm.bmBits=%p\n", res, bmp, bm.bmBits);
2032  if (bm.bmBits)
2033  {
2034  // MmUnsecureVirtualMemory(hSecure); // FIXME: Implement this!
2035  if (section)
2036  {
2037  ZwUnmapViewOfSection(NtCurrentProcess(), mapBits);
2038  bm.bmBits = NULL;
2039  }
2040  else if (!offset)
2041  EngFreeUserMem(bm.bmBits), bm.bmBits = NULL;
2042  }
2043 
2044  if (bmp)
2045  {
2047  bmp = NULL;
2048  }
2049 
2050  if (res)
2051  {
2053  res = 0;
2054  }
2055 
2056  if(ppalDIB)
2057  {
2058  PALETTE_ShareUnlockPalette(ppalDIB);
2059  }
2060  }
2061 
2062  if (bmp)
2063  {
2064  /* If we're here, everything went fine */
2065  SURFACE_vSetPalette(bmp, ppalDIB);
2066  PALETTE_ShareUnlockPalette(ppalDIB);
2068  }
2069 
2070  // Return BITMAP handle and storage location
2071  if (NULL != bm.bmBits && NULL != bits)
2072  {
2073  *bits = bm.bmBits;
2074  }
2075 
2076  return res;
2077 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define abs(i)
Definition: fconv.c:206
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: swimpl.c:16
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
#define DIB_PAL_COLORS
Definition: wingdi.h:365
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
LONG NTSTATUS
Definition: precomp.h:26
#define BMF_TOPDOWN
Definition: winddi.h:1180
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
Definition: parser.c:55
PPALETTE NTAPI CreateDIBPalette(_In_ const BITMAPINFO *pbmi, _In_ PDC pdc, _In_ ULONG iUsage)
Definition: dibobj.c:41
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
int32_t INT
Definition: typedefs.h:58
#define BI_BITFIELDS
Definition: mmreg.h:507
#define ERROR_NO_SYSTEM_RESOURCES
Definition: winerror.h:931
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
#define BMF_DONTCACHE
Definition: winddi.h:1182
ENGAPI VOID APIENTRY EngFreeUserMem(_Pre_notnull_ __drv_freesMem(UserMem) PVOID pv)
ULONG FASTCALL BitmapFormat(ULONG cBits, ULONG iCompression)
Definition: surface.c:39
#define UlongToPtr(u)
Definition: config.h:106
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER SectionOffset
Definition: mmfuncs.h:404
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define BMF_USERMEM
Definition: winddi.h:1183
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GLintptr offset
Definition: glext.h:5920
PVOID HANDLE
Definition: typedefs.h:73
unsigned long DWORD
Definition: ntddk_ex.h:95
#define BMF_NOZEROINIT
Definition: winddi.h:1181
BITMAP bmp
Definition: alphablend.c:62
FORCEINLINE VOID SURFACE_vSetPalette(_Inout_ PSURFACE psurf, _In_ PPALETTE ppal)
Definition: surface.h:136
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
ULONG_PTR SIZE_T
Definition: typedefs.h:80
Definition: bl.h:1331
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
HBITMAP NTAPI GreCreateBitmapEx(_In_ ULONG nWidth, _In_ ULONG nHeight, _In_ ULONG cjWidthBytes, _In_ ULONG iFormat, _In_ USHORT fjBitmap, _In_ ULONG cjSizeImage, _In_opt_ PVOID pvBits, _In_ FLONG flags)
Definition: bitmaps.c:101
#define NULL
Definition: types.h:112
#define BI_RLE4
Definition: precomp.h:48
#define DPRINT1
Definition: precomp.h:8
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
char * cleanup(char *str)
Definition: wpickclick.c:99
static const WCHAR dc[]
static HBITMAP
Definition: button.c:44
#define DPRINT
Definition: sndvol32.h:71
#define BI_RLE8
Definition: wingdi.h:35
#define BI_RGB
Definition: precomp.h:47
#define CONST
Definition: pedump.c:81
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define PAGE_READWRITE
Definition: nt_native.h:1304

Referenced by GreGetDIBitsInternal(), IntCreateCompatibleBitmap(), and NtGdiCreateDIBSection().

◆ DIB_FreeConvertedBitmapInfo()

VOID FASTCALL DIB_FreeConvertedBitmapInfo ( BITMAPINFO converted,
BITMAPINFO orig,
DWORD  Usage 
)

Definition at line 2271 of file dibobj.c.

2272 {
2273  BITMAPCOREINFO* pbmci;
2274  if(converted == orig)
2275  return;
2276 
2277  if(usage == -1)
2278  {
2279  /* Caller don't want any conversion */
2280  ExFreePoolWithTag(converted, TAG_DIB);
2281  return;
2282  }
2283 
2284  /* Perform inverse conversion */
2285  pbmci = (BITMAPCOREINFO*)orig;
2286 
2287  ASSERT(pbmci->bmciHeader.bcSize == sizeof(BITMAPCOREHEADER));
2288  pbmci->bmciHeader.bcBitCount = converted->bmiHeader.biBitCount;
2289  pbmci->bmciHeader.bcWidth = converted->bmiHeader.biWidth;
2290  pbmci->bmciHeader.bcHeight = converted->bmiHeader.biHeight;
2291  pbmci->bmciHeader.bcPlanes = converted->bmiHeader.biPlanes;
2292 
2293  if(pbmci->bmciHeader.bcBitCount <= 8)
2294  {
2295  UINT numColors = converted->bmiHeader.biClrUsed;
2296  if(!numColors) numColors = 1 << pbmci->bmciHeader.bcBitCount;
2297  if(usage == DIB_PAL_COLORS)
2298  {
2299  RtlZeroMemory(pbmci->bmciColors, (1 << pbmci->bmciHeader.bcBitCount) * sizeof(WORD));
2300  RtlCopyMemory(pbmci->bmciColors, converted->bmiColors, numColors * sizeof(WORD));
2301  }
2302  else
2303  {
2304  UINT i;
2305  RtlZeroMemory(pbmci->bmciColors, (1 << pbmci->bmciHeader.bcBitCount) * sizeof(RGBTRIPLE));
2306  for(i=0; i<numColors; i++)
2307  {
2308  pbmci->bmciColors[i].rgbtRed = converted->bmiColors[i].rgbRed;
2309  pbmci->bmciColors[i].rgbtGreen = converted->bmiColors[i].rgbGreen;
2310  pbmci->bmciColors[i].rgbtBlue = converted->bmiColors[i].rgbBlue;
2311  }
2312  }
2313  }
2314  /* Now free it, it's not needed anymore */
2315  ExFreePoolWithTag(converted, TAG_DIB);
2316 }
BYTE rgbtBlue
Definition: wingdi.h:1437
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
#define DIB_PAL_COLORS
Definition: wingdi.h:365
BITMAPCOREHEADER bmciHeader
Definition: wingdi.h:1452
RGBTRIPLE bmciColors[1]
Definition: wingdi.h:1453
#define ASSERT(a)
Definition: mode.c:44
RGBQUAD bmiColors[1]
Definition: wingdi.h:1476
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BYTE rgbtRed
Definition: wingdi.h:1439
unsigned int UINT
Definition: ndis.h:50
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
BYTE rgbtGreen
Definition: wingdi.h:1438
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define TAG_DIB
Definition: tags.h:17

Referenced by GreGetDIBitsInternal(), IntSynthesizeBitmap(), and UserLoadImage().

◆ DIB_GetBitmapInfo()

int FASTCALL DIB_GetBitmapInfo ( const BITMAPINFOHEADER header,
LONG width,
LONG height,
WORD planes,
WORD bpp,
DWORD compr,
DWORD size 
)

Definition at line 2087 of file dibobj.c.

2089 {
2090  if (header->biSize == sizeof(BITMAPCOREHEADER))
2091  {
2092  const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)header;
2093  *width = core->bcWidth;
2094  *height = core->bcHeight;
2095  *planes = core->bcPlanes;
2096  *bpp = core->bcBitCount;
2097  *compr = BI_RGB;
2098  *size = 0;
2099  return 0;
2100  }
2101  if (header->biSize >= sizeof(BITMAPINFOHEADER)) /* Assume BITMAPINFOHEADER */
2102  {
2103  *width = header->biWidth;
2104  *height = header->biHeight;
2105  *planes = header->biPlanes;
2106  *bpp = header->biBitCount;
2107  *compr = header->biCompression;
2108  *size = header->biSizeImage;
2109  return 1;
2110  }
2111  DPRINT1("(%u): unknown/wrong size for header\n", header->biSize );
2112  return -1;
2113 }
GLint GLint GLsizei width
Definition: gl.h:1546
static int __cdecl compr(const void *a, const void *b)
Definition: bidi.c:641
GLsizeiptr size
Definition: glext.h:5919
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define DPRINT1
Definition: precomp.h:8
DWORD bpp
Definition: surface.c:185
#define BI_RGB
Definition: precomp.h:47

Referenced by GreGetDIBitsInternal().

◆ DIB_GetDIBImageBytes()

INT APIENTRY DIB_GetDIBImageBytes ( INT  width,
INT  height,
INT  depth 
)

Definition at line 2122 of file dibobj.c.

2123 {
2124  return WIDTH_BYTES_ALIGN32(width, depth) * (height < 0 ? -height : height);
2125 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: swimpl.c:16
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546

Referenced by DIB_ConvertBitmapInfo(), GreGetDIBitsInternal(), and IntSetDIBits().

◆ DIB_MapPaletteColors()

HPALETTE FASTCALL DIB_MapPaletteColors ( PPALETTE  ppal,
CONST BITMAPINFO lpbmi 
)

Definition at line 2163 of file dibobj.c.

2164 {
2165  PPALETTE ppalNew;
2166  ULONG nNumColors,i;
2167  USHORT *lpIndex;
2168  HPALETTE hpal;
2169 
2170  if (!(ppalDc->flFlags & PAL_INDEXED))
2171  {
2172  return NULL;
2173  }
2174 
2175  nNumColors = 1 << lpbmi->bmiHeader.biBitCount;
2176  if (lpbmi->bmiHeader.biClrUsed)
2177  {
2178  nNumColors = min(nNumColors, lpbmi->bmiHeader.biClrUsed);
2179  }
2180 
2181  ppalNew = PALETTE_AllocPalWithHandle(PAL_INDEXED, nNumColors, NULL, 0, 0, 0);
2182  if (ppalNew == NULL)
2183  {
2184  DPRINT1("Could not allocate palette\n");
2185  return NULL;
2186  }
2187 
2188  lpIndex = (USHORT *)((PBYTE)lpbmi + lpbmi->bmiHeader.biSize);
2189 
2190  for (i = 0; i < nNumColors; i++)
2191  {
2192  ULONG iColorIndex = *lpIndex % ppalDc->NumColors;
2193  ppalNew->IndexedColors[i] = ppalDc->IndexedColors[iColorIndex];
2194  lpIndex++;
2195  }
2196 
2197  hpal = ppalNew->BaseObject.hHmgr;
2198  PALETTE_UnlockPalette(ppalNew);
2199 
2200  return hpal;
2201 }
PALETTEENTRY * IndexedColors
Definition: palette.h:42
#define PALETTE_UnlockPalette(pPalette)
Definition: palette.h:56
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:209
BASEOBJECT BaseObject
Definition: palette.h:36
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned short USHORT
Definition: pedump.c:61
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
BYTE * PBYTE
Definition: pedump.c:66

◆ GreCreateDIBitmapFromPackedDIB()

HBITMAP NTAPI GreCreateDIBitmapFromPackedDIB ( _In_reads_(cjPackedDIB) PVOID  pvPackedDIB,
_In_ UINT  cjPackedDIB,
_In_ ULONG  uUsage 
)

Definition at line 1762 of file dibobj.c.

1766 {
1767  PBITMAPINFO pbmi;
1768  PBYTE pjBits;
1769  UINT cjInfo, cjBits;
1770  HBITMAP hbm;
1771 
1772  /* We only support BITMAPINFOHEADER, make sure the size is ok */
1773  if (cjPackedDIB < sizeof(BITMAPINFOHEADER))
1774  {
1775  return NULL;
1776  }
1777 
1778  /* The packed DIB starts with the BITMAPINFOHEADER */
1779  pbmi = pvPackedDIB;
1780 
1781  if (cjPackedDIB < pbmi->bmiHeader.biSize)
1782  {
1783  return NULL;
1784  }
1785 
1786  /* Calculate the info size and make sure the packed DIB is large enough */
1787  cjInfo = DIB_BitmapInfoSize(pbmi, uUsage);
1788  if (cjPackedDIB <= cjInfo)
1789  {
1790  return NULL;
1791  }
1792 
1793  /* The bitmap bits start after the header */
1794  pjBits = (PBYTE)pvPackedDIB + cjInfo;
1795  cjBits = cjPackedDIB - cjInfo;
1796 
1801  pjBits,
1802  pbmi,
1803  uUsage,
1804  0,
1805  cjBits,
1806  NULL);
1807 
1808  return hbm;
1809 }
#define abs(i)
Definition: fconv.c:206
HBITMAP NTAPI GreCreateDIBitmapInternal(IN HDC hDc, IN INT cx, IN INT cy, IN DWORD fInit, IN OPTIONAL LPBYTE pjInit, IN OPTIONAL PBITMAPINFO pbmi, IN DWORD iUsage, IN FLONG fl, IN UINT cjMaxBits, IN HANDLE hcmXform)
Definition: dibobj.c:1686
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
INT FASTCALL DIB_BitmapInfoSize(const BITMAPINFO *info, WORD coloruse)
Definition: dibobj.c:2134
#define CBM_INIT
Definition: wingdi.h:364
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define CBM_CREATDIB
static HBITMAP
Definition: button.c:44
BYTE * PBYTE
Definition: pedump.c:66

Referenced by NtGdiCreateDIBBrush().

◆ GreGetDIBitsInternal()

INT APIENTRY GreGetDIBitsInternal ( HDC  hDC,
HBITMAP  hBitmap,
UINT  StartScan,
UINT  ScanLines,
LPBYTE  Bits,
LPBITMAPINFO  Info,
UINT  Usage,
UINT  MaxBits,
UINT  MaxInfo 
)

Definition at line 690 of file dibobj.c.

700 {
701  BITMAPCOREINFO* pbmci = NULL;
702  PSURFACE psurf = NULL;
703  PDC pDC;
704  LONG width, height;
705  WORD planes, bpp;
706  DWORD compr, size ;
707  USHORT i;
708  int bitmap_type;
709  RGBQUAD* rgbQuads;
710  VOID* colorPtr;
711 
712  DPRINT("Entered GreGetDIBitsInternal()\n");
713 
714  if ((Usage && Usage != DIB_PAL_COLORS) || !Info || !hBitmap)
715  return 0;
716 
717  pDC = DC_LockDc(hDC);
718  if (pDC == NULL || pDC->dctype == DC_TYPE_INFO)
719  {
720  ScanLines = 0;
721  goto done;
722  }
723 
724  /* Get a pointer to the source bitmap object */
726  if (psurf == NULL)
727  {
728  ScanLines = 0;
729  goto done;
730  }
731 
732  colorPtr = (LPBYTE)Info + Info->bmiHeader.biSize;
733  rgbQuads = colorPtr;
734 
735  bitmap_type = DIB_GetBitmapInfo(&Info->bmiHeader,
736  &width,
737  &height,
738  &planes,
739  &bpp,
740  &compr,
741  &size);
742  if(bitmap_type == -1)
743  {
744  DPRINT1("Wrong bitmap format\n");
746  ScanLines = 0;
747  goto done;
748  }
749  else if(bitmap_type == 0)
750  {
751  /* We need a BITMAPINFO to create a DIB, but we have to fill
752  * the BITMAPCOREINFO we're provided */
753  pbmci = (BITMAPCOREINFO*)Info;
754  /* fill in the the bit count, so we can calculate the right ColorsSize during the conversion */
757  if(Info == NULL)
758  {
759  DPRINT1("Error, could not convert the BITMAPCOREINFO!\n");
760  ScanLines = 0;
761  goto done;
762  }
763  rgbQuads = Info->bmiColors;
764  }
765 
766  /* Validate input:
767  - negative width is always an invalid value
768  - non-null Bits and zero bpp is an invalid combination
769  - only check the rest of the input params if either bpp is non-zero or Bits are set */
770  if (width < 0 || (bpp == 0 && Bits))
771  {
772  ScanLines = 0;
773  goto done;
774  }
775 
776  if (Bits || bpp)
777  {
778  if ((height == 0 || width == 0) || (compr && compr != BI_BITFIELDS && compr != BI_RGB))
779  {
780  ScanLines = 0;
781  goto done;
782  }
783  }
784 
785  Info->bmiHeader.biClrUsed = 0;
786  Info->bmiHeader.biClrImportant = 0;
787 
788  /* Fill in the structure */
789  switch(bpp)
790  {
791  case 0: /* Only info */
792  Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx;
793  Info->bmiHeader.biHeight = (psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ?
794  -psurf->SurfObj.sizlBitmap.cy :
795  psurf->SurfObj.sizlBitmap.cy;
796  Info->bmiHeader.biPlanes = 1;
797  Info->bmiHeader.biBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
798  Info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes( Info->bmiHeader.biWidth,
799  Info->bmiHeader.biHeight,
800  Info->bmiHeader.biBitCount);
801  Info->bmiHeader.biCompression = (Info->bmiHeader.biBitCount == 16 || Info->bmiHeader.biBitCount == 32) ?
803  Info->bmiHeader.biXPelsPerMeter = 0;
804  Info->bmiHeader.biYPelsPerMeter = 0;
805 
806  if (Info->bmiHeader.biBitCount <= 8 && Info->bmiHeader.biClrUsed == 0)
807  Info->bmiHeader.biClrUsed = 1 << Info->bmiHeader.biBitCount;
808 
809  ScanLines = 1;
810  goto done;
811 
812  case 1:
813  case 4:
814  case 8:
815  Info->bmiHeader.biClrUsed = 1 << bpp;
816 
817  /* If the bitmap is a DIB section and has the same format as what
818  * is requested, go ahead! */
819  if((psurf->hSecure) &&
820  (BitsPerFormat(psurf->SurfObj.iBitmapFormat) == bpp))
821  {
822  if(Usage == DIB_RGB_COLORS)
823  {
824  ULONG colors = min(psurf->ppal->NumColors, 256);
825  if(colors != 256) Info->bmiHeader.biClrUsed = colors;
826  for(i = 0; i < colors; i++)
827  {
828  rgbQuads[i].rgbRed = psurf->ppal->IndexedColors[i].peRed;
829  rgbQuads[i].rgbGreen = psurf->ppal->IndexedColors[i].peGreen;
830  rgbQuads[i].rgbBlue = psurf->ppal->IndexedColors[i].peBlue;
831  rgbQuads[i].rgbReserved = 0;
832  }
833  }
834  else
835  {
836  for(i = 0; i < 256; i++)
837  ((WORD*)rgbQuads)[i] = i;
838  }
839  }
840  else
841  {
842  if(Usage == DIB_PAL_COLORS)
843  {
844  for(i = 0; i < 256; i++)
845  {
846  ((WORD*)rgbQuads)[i] = i;
847  }
848  }
849  else if(bpp > 1 && bpp == BitsPerFormat(psurf->SurfObj.iBitmapFormat))
850  {
851  /* For color DDBs in native depth (mono DDBs always have
852  a black/white palette):
853  Generate the color map from the selected palette */
854  PPALETTE pDcPal = PALETTE_ShareLockPalette(pDC->dclevel.hpal);
855  if(!pDcPal)
856  {
857  ScanLines = 0 ;
858  goto done ;
859  }
860  for (i = 0; i < pDcPal->NumColors; i++)
861  {
862  rgbQuads[i].rgbRed = pDcPal->IndexedColors[i].peRed;
863  rgbQuads[i].rgbGreen = pDcPal->IndexedColors[i].peGreen;
864  rgbQuads[i].rgbBlue = pDcPal->IndexedColors[i].peBlue;
865  rgbQuads[i].rgbReserved = 0;
866  }
868  }
869  else
870  {
871  switch (bpp)
872  {
873  case 1:
874  rgbQuads[0].rgbRed = rgbQuads[0].rgbGreen = rgbQuads[0].rgbBlue = 0;
875  rgbQuads[0].rgbReserved = 0;
876  rgbQuads[1].rgbRed = rgbQuads[1].rgbGreen = rgbQuads[1].rgbBlue = 0xff;
877  rgbQuads[1].rgbReserved = 0;
878  break;
879 
880  case 4:
881  /* The EGA palette is the first and last 8 colours of the default palette
882  with the innermost pair swapped */
883  RtlCopyMemory(rgbQuads, DefLogPaletteQuads, 7 * sizeof(RGBQUAD));
884  RtlCopyMemory(rgbQuads + 7, DefLogPaletteQuads + 12, 1 * sizeof(RGBQUAD));
885  RtlCopyMemory(rgbQuads + 8, DefLogPaletteQuads + 7, 1 * sizeof(RGBQUAD));
886  RtlCopyMemory(rgbQuads + 9, DefLogPaletteQuads + 13, 7 * sizeof(RGBQUAD));
887  break;
888 
889  case 8:
890  {
891  INT i;
892 
893  memcpy(rgbQuads, DefLogPaletteQuads, 10 * sizeof(RGBQUAD));
894  memcpy(rgbQuads + 246, DefLogPaletteQuads + 10, 10 * sizeof(RGBQUAD));
895 
896  for (i = 10; i < 246; i++)
897  {
898  rgbQuads[i].rgbRed = (i & 0x07) << 5;
899  rgbQuads[i].rgbGreen = (i & 0x38) << 2;
900  rgbQuads[i].rgbBlue = i & 0xc0;
901  rgbQuads[i].rgbReserved = 0;
902  }
903  }
904  }
905  }
906  }
907  break;
908 
909  case 15:
910  if (Info->bmiHeader.biCompression == BI_BITFIELDS)
911  {
912  ((PDWORD)Info->bmiColors)[0] = 0x7c00;
913  ((PDWORD)Info->bmiColors)[1] = 0x03e0;
914  ((PDWORD)Info->bmiColors)[2] = 0x001f;
915  }
916  break;
917 
918  case 16:
919  if (Info->bmiHeader.biCompression == BI_BITFIELDS)
920  {
921  if (psurf->hSecure)
922  {
923  ((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask;
924  ((PDWORD)Info->bmiColors)[1] = psurf->ppal->GreenMask;
925  ((PDWORD)Info->bmiColors)[2] = psurf->ppal->BlueMask;
926  }
927  else
928  {
929  ((PDWORD)Info->bmiColors)[0] = 0xf800;
930  ((PDWORD)Info->bmiColors)[1] = 0x07e0;
931  ((PDWORD)Info->bmiColors)[2] = 0x001f;
932  }
933  }
934  break;
935 
936  case 24:
937  case 32:
938  if (Info->bmiHeader.biCompression == BI_BITFIELDS)
939  {
940  if (psurf->hSecure)
941  {
942  ((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask;
943  ((PDWORD)Info->bmiColors)[1] = psurf->ppal->GreenMask;
944  ((PDWORD)Info->bmiColors)[2] = psurf->ppal->BlueMask;
945  }
946  else
947  {
948  ((PDWORD)Info->bmiColors)[0] = 0xff0000;
949  ((PDWORD)Info->bmiColors)[1] = 0x00ff00;
950  ((PDWORD)Info->bmiColors)[2] = 0x0000ff;
951  }
952  }
953  break;
954 
955  default:
956  ScanLines = 0;
957  goto done;
958  }
959 
960  Info->bmiHeader.biSizeImage = DIB_GetDIBImageBytes(width, height, bpp);
961  Info->bmiHeader.biPlanes = 1;
962 
963  if(Bits && ScanLines)
964  {
965  /* Create a DIBSECTION, blt it, profit */
966  PVOID pDIBits ;
967  HBITMAP hBmpDest;
968  PSURFACE psurfDest;
969  EXLATEOBJ exlo;
970  RECT rcDest;
971  POINTL srcPoint;
972  BOOL ret ;
973  int newLines = -1;
974 
975  if (StartScan >= abs(Info->bmiHeader.biHeight))
976  {
977  ScanLines = 1;
978  goto done;
979  }
980  else
981  {
982  ScanLines = min(ScanLines, abs(Info->bmiHeader.biHeight) - StartScan);
983  }
984 
985  if (abs(Info->bmiHeader.biHeight) < psurf->SurfObj.sizlBitmap.cy)
986  {
987  StartScan += psurf->SurfObj.sizlBitmap.cy - abs(Info->bmiHeader.biHeight);
988  }
989  /* Fixup values */
990  Info->bmiHeader.biHeight = (height < 0) ?
991  -(LONG)ScanLines : ScanLines;
992  /* Create the DIB */
993  hBmpDest = DIB_CreateDIBSection(pDC, Info, Usage, &pDIBits, NULL, 0, 0);
994  /* Restore them */
995  Info->bmiHeader.biHeight = height;
996 
997  if(!hBmpDest)
998  {
999  DPRINT1("Unable to create a DIB Section!\n");
1001  ScanLines = 0;
1002  goto done ;
1003  }
1004 
1005  psurfDest = SURFACE_ShareLockSurface(hBmpDest);
1006 
1007  RECTL_vSetRect(&rcDest, 0, 0, Info->bmiHeader.biWidth, ScanLines);
1008  Info->bmiHeader.biWidth = width;
1009  srcPoint.x = 0;
1010 
1011  if (abs(Info->bmiHeader.biHeight) <= psurf->SurfObj.sizlBitmap.cy)
1012  {
1013  srcPoint.y = psurf->SurfObj.sizlBitmap.cy - StartScan - ScanLines;
1014  }
1015  else
1016  {
1017  /* Determine the actual number of lines copied from the */
1018  /* original bitmap. It might be different from ScanLines. */
1019  newLines = abs(Info->bmiHeader.biHeight) - psurf->SurfObj.sizlBitmap.cy;
1020  newLines = min((int)(StartScan + ScanLines - newLines), psurf->SurfObj.sizlBitmap.cy);
1021  if (newLines > 0)
1022  {
1023  srcPoint.y = psurf->SurfObj.sizlBitmap.cy - newLines;
1024  if (StartScan > psurf->SurfObj.sizlBitmap.cy)
1025  {
1026  newLines -= (StartScan - psurf->SurfObj.sizlBitmap.cy);
1027  }
1028  }
1029  else
1030  {
1031  newLines = 0;
1032  srcPoint.y = psurf->SurfObj.sizlBitmap.cy;
1033  }
1034  }
1035 
1036  EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0xffffff, 0xffffff, 0);
1037 
1038  ret = IntEngCopyBits(&psurfDest->SurfObj,
1039  &psurf->SurfObj,
1040  NULL,
1041  &exlo.xlo,
1042  &rcDest,
1043  &srcPoint);
1044 
1045  SURFACE_ShareUnlockSurface(psurfDest);
1046 
1047  if(!ret)
1048  ScanLines = 0;
1049  else
1050  {
1051  RtlCopyMemory(Bits, pDIBits, DIB_GetDIBImageBytes (width, ScanLines, bpp));
1052  }
1053  /* Update if line count has changed */
1054  if (newLines != -1)
1055  {
1056  ScanLines = (UINT)newLines;
1057  }
1058  GreDeleteObject(hBmpDest);
1059  EXLATEOBJ_vCleanup(&exlo);
1060  }
1061  else
1062  {
1063  /* Signals success and not the actual number of scan lines*/
1064  ScanLines = 1;
1065  }
1066 
1067 done:
1068 
1069  if (pbmci)
1071 
1072  if (psurf)
1074 
1075  if (pDC)
1076  DC_UnlockDc(pDC);
1077 
1078  return ScanLines;
1079 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define abs(i)
Definition: fconv.c:206
GLint GLint GLsizei width
Definition: gl.h:1546
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
SIZEL sizlBitmap
Definition: winddi.h:1209
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:219
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
#define DIB_PAL_COLORS
Definition: wingdi.h:365
HBITMAP APIENTRY DIB_CreateDIBSection(PDC dc, CONST BITMAPINFO *bmi, UINT usage, LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch)
Definition: dibobj.c:1880
#define BitsPerFormat(Format)
Definition: surface.h:109
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:382
static const RGBQUAD DefLogPaletteQuads[20]
Definition: dibobj.c:14
PALETTEENTRY * IndexedColors
Definition: palette.h:42
struct _PALETTE *const ppal
Definition: surface.h:11
#define BMF_TOPDOWN
Definition: winddi.h:1180
ULONG iBitmapFormat
Definition: winddi.h:1215
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
int32_t INT
Definition: typedefs.h:58
#define BI_BITFIELDS
Definition: mmreg.h:507
LONG y
Definition: windef.h:330
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
BITMAPCOREHEADER bmciHeader
Definition: wingdi.h:1452
XLATEOBJ xlo
Definition: xlateobj.h:21
BITMAPINFO *FASTCALL DIB_ConvertBitmapInfo(CONST BITMAPINFO *pbmi, DWORD Usage)
Definition: dibobj.c:2207
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:358
unsigned char * LPBYTE
Definition: typedefs.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
int FASTCALL DIB_GetBitmapInfo(const BITMAPINFOHEADER *header, LONG *width, LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size)
Definition: dibobj.c:2087
SURFOBJ SurfObj
Definition: surface.h:8
static int __cdecl compr(const void *a, const void *b)
Definition: bidi.c:641
LONG cx
Definition: windef.h:334
BOOL APIENTRY IntEngCopyBits(SURFOBJ *psoTrg, SURFOBJ *psoSrc, CLIPOBJ *pco, XLATEOBJ *pxlo, RECTL *prclTrg, POINTL *pptlSrc)
Definition: bitblt_new.c:678
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:649
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
Definition: polytest.cpp:40
GLsizeiptr size
Definition: glext.h:5919
ULONG RGBQUAD
Definition: precomp.h:50
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG x
Definition: windef.h:329
INT APIENTRY DIB_GetDIBImageBytes(INT width, INT height, INT depth)
Definition: dibobj.c:2122
int ret
HANDLE hSecure
Definition: surface.h:32
VOID FASTCALL DIB_FreeConvertedBitmapInfo(BITMAPINFO *converted, BITMAPINFO *orig, DWORD usage)
Definition: dibobj.c:2271
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG NumColors
Definition: palette.h:41
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
USHORT fjBitmap
Definition: winddi.h:1217
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE VOID RECTL_vSetRect(_Out_ RECTL *prcl, _In_ LONG left, _In_ LONG top, _In_ LONG right, _In_ LONG bottom)
Definition: rect.h:5
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:237
#define DC_TYPE_INFO
Definition: ntgdihdl.h:125
unsigned short USHORT
Definition: pedump.c:61
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
DWORD * PDWORD
Definition: pedump.c:68
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
DWORD bpp
Definition: surface.c:185
static HBITMAP
Definition: button.c:44
#define DPRINT
Definition: sndvol32.h:71
#define DIB_RGB_COLORS
Definition: wingdi.h:366
LONG cy
Definition: windef.h:335
#define BI_RGB
Definition: precomp.h:47
static HBITMAP hBitmap
Definition: timezone.c:26
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27

Referenced by _Success_(), and IntSynthesizeDib().