
Sun Mar 19 16:30:20 1995 Alexandre Julliard (julliard@sunsite.unc.edu) * [*/*] Implemented a new memory mapping scheme. There's no longer a one-to-one mapping between 16-bit and 32-bit pointers. Please see file DEVELOPERS-HINTS for technical details. * [controls/scroll.c] Fixed bug when dragging mouse in horizontal scrollbars. * [tools/build.c] [if1632/*.spec] Removed support for C callback functions and for re-ordering of the 32-bit arguments, as these were never used. This should allow a more efficient callback scheme to be implemented. * [if1632/olecli.spec] Reduced the number of entries to make the 16-bit code fit in 64k. This limitation will soon be removed. * [loader/ldt.c] Rewrote LDT manipulation functions and implemented LDT_GetEntry(). * [memory/global.c] Rewrote Global*() routines to use the new selector allocation mechanism. * [memory/local.c] Rewrote local heap handling to use a Windows-compatible layout (not really finished yet). Implemented TOOLHELP heap-walking routines. * [memory/selector.c] Implemented LDT manipulation API functions. Tue Mar 14 19:50:28 EST 1995 William Magro (wmagro@tc.cornell.edu) * [windows/defdlg.c] Fixed problem where dialogs closed using the System menu ('Close' item or double click on close box) would hang Wine. Sun Mar 12 14:28:13 1995 Michael Patra <micky@marie.physik.TU-Berlin.DE> * [controls/listbox.c] Removed most of the statements for sending a notification message ListBoxDirectory(), DlgDirSelect(), DlgDirList(): Improved the code; Borland's standard file open dialog will work now. * [misc/main.c], [misc/file.c], [miscemu/int21.c] Added support for new command line option "-allowreadonly". If set an attempt to open a read only file in write mode will be converted to opening it read only (many programs try to open all files in read/write mode even if they only intend to read it - this might cause a few under problems under an unix-like environment where most files are read only for a "normal" user) * [loader/selector.c] GetMemoryReference(): Added support for __AHIncr and __AHShift * [misc/dos_fs.c] DOS_SimplifyPath(): This routine simplifies path names ( e.g., it will change "/usr///local/bin/../lib//a" to "/usr/local/lib/a" ) match(): rewritten * [objects/text.c] TEXT_NextLine(): Removed a bug in the handling of LF's * [miscemu/int21.c] GetFileDateTime(): Fixed. SetFileDateTime() is still broken. Sat Mar 11 19:46:19 1995 Martin von Loewis <loewis@informatik.hu-berlin.de> * [controls/menu.c] ChangeMenu: defaults to MF_INSERT InsertMenu: allow insertion even if position is one after last item * [if1632/Imakefile] [if1632/compobj.spec] [if1632/relay.c] [if1632/storage.spec] [include/dlls.h] Added stubs for STORAGE.DLL and COMPOBJ.DLL * [if1632/user.spec] [windows/message.c] InSendMessage: new function * [include/neexe.h][include/ne_image.c] NE_FixupSegment: fixed handling of additive records * [loader/selector.c] GetEntryDLLName: return NULL instead of pointer to DLL.0 if not found * [loader/signal.c] win_fault: Enter debugger on SIGFPE, too Wed Mar 1 21:47:42 1995 Cameron Heide (heide@ee.ualberta.ca) * [miscemu/int*.c] Various minor modifications to the clock tick counter, FindFirst/FindNext funcs, and DPB handling.
314 lines
9.1 KiB
C
314 lines
9.1 KiB
C
/*
|
|
* GDI bitmap objects
|
|
*
|
|
* Copyright 1993 Alexandre Julliard
|
|
*
|
|
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <X11/Xlib.h>
|
|
#include <X11/Xutil.h>
|
|
#include "gdi.h"
|
|
#include "dc.h"
|
|
#include "bitmap.h"
|
|
#include "stddebug.h"
|
|
/* #define DEBUG_GDI */
|
|
/* #define DEBUG_BITMAP */
|
|
#include "debug.h"
|
|
|
|
/* GCs used for B&W and color bitmap operations */
|
|
GC BITMAP_monoGC = 0, BITMAP_colorGC = 0;
|
|
|
|
extern void CLIPPING_UpdateGCRegion( DC * dc ); /* objects/clipping.c */
|
|
|
|
/***********************************************************************
|
|
* BITMAP_Init
|
|
*/
|
|
BOOL BITMAP_Init(void)
|
|
{
|
|
Pixmap tmpPixmap;
|
|
|
|
/* Create the necessary GCs */
|
|
|
|
if ((tmpPixmap = XCreatePixmap( display, rootWindow, 1, 1, 1 )))
|
|
{
|
|
BITMAP_monoGC = XCreateGC( display, tmpPixmap, 0, NULL );
|
|
XSetGraphicsExposures( display, BITMAP_monoGC, False );
|
|
XFreePixmap( display, tmpPixmap );
|
|
}
|
|
|
|
if (screenDepth != 1)
|
|
{
|
|
if ((tmpPixmap = XCreatePixmap(display, rootWindow, 1,1,screenDepth)))
|
|
{
|
|
BITMAP_colorGC = XCreateGC( display, tmpPixmap, 0, NULL );
|
|
XSetGraphicsExposures( display, BITMAP_colorGC, False );
|
|
XFreePixmap( display, tmpPixmap );
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* BITMAP_BmpToImage
|
|
*
|
|
* Create an XImage pointing to the bitmap data.
|
|
*/
|
|
static XImage *BITMAP_BmpToImage( BITMAP * bmp, void * bmpData )
|
|
{
|
|
extern void _XInitImageFuncPtrs( XImage* );
|
|
XImage * image;
|
|
|
|
image = XCreateImage( display, DefaultVisualOfScreen(screen),
|
|
bmp->bmBitsPixel, ZPixmap, 0, bmpData,
|
|
bmp->bmWidth, bmp->bmHeight, 16, bmp->bmWidthBytes );
|
|
if (!image) return 0;
|
|
image->byte_order = MSBFirst;
|
|
image->bitmap_bit_order = MSBFirst;
|
|
image->bitmap_unit = 16;
|
|
_XInitImageFuncPtrs(image);
|
|
return image;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateBitmap (GDI.48)
|
|
*/
|
|
HBITMAP CreateBitmap( short width, short height,
|
|
BYTE planes, BYTE bpp, LPSTR bits )
|
|
{
|
|
BITMAP bitmap = { 0, width, height, 0, planes, bpp, bits };
|
|
dprintf_gdi(stddeb, "CreateBitmap: %dx%d, %d colors\n",
|
|
width, height, 1 << (planes*bpp) );
|
|
return CreateBitmapIndirect( &bitmap );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateCompatibleBitmap (GDI.51)
|
|
*/
|
|
HBITMAP CreateCompatibleBitmap( HDC hdc, short width, short height )
|
|
{
|
|
DC * dc;
|
|
dprintf_gdi(stddeb, "CreateCompatibleBitmap: %d %dx%d\n",
|
|
hdc, width, height );
|
|
if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
|
|
return CreateBitmap( width, height, 1, dc->w.bitsPerPixel, NULL );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CreateBitmapIndirect (GDI.49)
|
|
*/
|
|
HBITMAP CreateBitmapIndirect( BITMAP * bmp )
|
|
{
|
|
BITMAPOBJ * bmpObjPtr;
|
|
HBITMAP hbitmap;
|
|
|
|
/* Check parameters */
|
|
if (!bmp->bmHeight || !bmp->bmWidth) return 0;
|
|
if (bmp->bmPlanes != 1) return 0;
|
|
if ((bmp->bmBitsPixel != 1) && (bmp->bmBitsPixel != screenDepth)) return 0;
|
|
|
|
if (bmp->bmHeight < 0)
|
|
bmp->bmHeight = -bmp->bmHeight;
|
|
|
|
if (bmp->bmWidth < 0)
|
|
bmp->bmWidth = -bmp->bmWidth;
|
|
|
|
|
|
/* Create the BITMAPOBJ */
|
|
hbitmap = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC );
|
|
if (!hbitmap) return 0;
|
|
bmpObjPtr = (BITMAPOBJ *) GDI_HEAP_LIN_ADDR( hbitmap );
|
|
|
|
bmpObjPtr->size.cx = 0;
|
|
bmpObjPtr->size.cy = 0;
|
|
bmpObjPtr->bitmap = *bmp;
|
|
bmpObjPtr->bitmap.bmBits = NULL;
|
|
bmpObjPtr->bitmap.bmWidthBytes = (bmp->bmWidth*bmp->bmBitsPixel+15)/16 * 2;
|
|
|
|
/* Create the pixmap */
|
|
bmpObjPtr->pixmap = XCreatePixmap( display, rootWindow, bmp->bmWidth,
|
|
bmp->bmHeight, bmp->bmBitsPixel );
|
|
if (!bmpObjPtr->pixmap)
|
|
{
|
|
GDI_HEAP_FREE( hbitmap );
|
|
hbitmap = 0;
|
|
}
|
|
else if (bmp->bmBits) /* Set bitmap bits */
|
|
SetBitmapBits( hbitmap, bmpObjPtr->bitmap.bmHeight*bmpObjPtr->bitmap.bmWidthBytes, bmp->bmBits );
|
|
return hbitmap;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetBitmapBits (GDI.74)
|
|
*/
|
|
LONG GetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer )
|
|
{
|
|
BITMAPOBJ * bmp;
|
|
LONG height;
|
|
XImage * image;
|
|
|
|
bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
|
|
if (!bmp) return 0;
|
|
|
|
dprintf_bitmap(stddeb, "GetBitmapBits: %dx%d %d colors %p\n",
|
|
bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
|
|
1 << bmp->bitmap.bmBitsPixel, buffer );
|
|
/* Only get entire lines */
|
|
height = count / bmp->bitmap.bmWidthBytes;
|
|
if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
|
|
if (!height) return 0;
|
|
|
|
if (!(image = BITMAP_BmpToImage( &bmp->bitmap, buffer ))) return 0;
|
|
XGetSubImage( display, bmp->pixmap, 0, 0, bmp->bitmap.bmWidth, height,
|
|
AllPlanes, ZPixmap, image, 0, 0 );
|
|
image->data = NULL;
|
|
XDestroyImage( image );
|
|
return height * bmp->bitmap.bmWidthBytes;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* SetBitmapBits (GDI.106)
|
|
*/
|
|
LONG SetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer )
|
|
{
|
|
BITMAPOBJ * bmp;
|
|
LONG height;
|
|
XImage * image;
|
|
|
|
bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
|
|
if (!bmp) return 0;
|
|
|
|
dprintf_bitmap(stddeb, "SetBitmapBits: %dx%d %d colors %p\n",
|
|
bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
|
|
1 << bmp->bitmap.bmBitsPixel, buffer );
|
|
|
|
/* Only set entire lines */
|
|
height = count / bmp->bitmap.bmWidthBytes;
|
|
if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
|
|
if (!height) return 0;
|
|
|
|
if (!(image = BITMAP_BmpToImage( &bmp->bitmap, buffer ))) return 0;
|
|
XPutImage( display, bmp->pixmap, BITMAP_GC(bmp), image, 0, 0,
|
|
0, 0, bmp->bitmap.bmWidth, height );
|
|
image->data = NULL;
|
|
XDestroyImage( image );
|
|
return height * bmp->bitmap.bmWidthBytes;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* BITMAP_DeleteObject
|
|
*/
|
|
BOOL BITMAP_DeleteObject( HBITMAP hbitmap, BITMAPOBJ * bitmap )
|
|
{
|
|
XFreePixmap( display, bitmap->pixmap );
|
|
return GDI_FreeObject( hbitmap );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* BITMAP_GetObject
|
|
*/
|
|
int BITMAP_GetObject( BITMAPOBJ * bmp, int count, LPSTR buffer )
|
|
{
|
|
if (count > sizeof(BITMAP)) count = sizeof(BITMAP);
|
|
memcpy( buffer, &bmp->bitmap, count );
|
|
return count;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* BITMAP_SelectObject
|
|
*/
|
|
HBITMAP BITMAP_SelectObject( HDC hdc, DC * dc, HBITMAP hbitmap,
|
|
BITMAPOBJ * bmp )
|
|
{
|
|
HRGN hrgn;
|
|
HBITMAP prevHandle = dc->w.hBitmap;
|
|
|
|
if (!(dc->w.flags & DC_MEMORY)) return 0;
|
|
hrgn = CreateRectRgn( 0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight );
|
|
if (!hrgn) return 0;
|
|
|
|
DeleteObject( dc->w.hVisRgn );
|
|
dc->w.hVisRgn = hrgn;
|
|
dc->u.x.drawable = bmp->pixmap;
|
|
dc->w.hBitmap = hbitmap;
|
|
|
|
/* Change GC depth if needed */
|
|
|
|
if (dc->w.bitsPerPixel != bmp->bitmap.bmBitsPixel)
|
|
{
|
|
XFreeGC( display, dc->u.x.gc );
|
|
dc->u.x.gc = XCreateGC( display, dc->u.x.drawable, 0, NULL );
|
|
dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
|
|
DC_InitDC( hdc );
|
|
}
|
|
else CLIPPING_UpdateGCRegion( dc ); /* Just update GC clip region */
|
|
return prevHandle;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* CreateDiscardableBitmap (GDI.156)
|
|
*/
|
|
HBITMAP CreateDiscardableBitmap(HDC hdc, short width, short height)
|
|
{
|
|
dprintf_bitmap(stddeb,"CreateDiscardableBitmap(%04X, %d, %d); "
|
|
"// call CreateCompatibleBitmap() for now!\n",
|
|
hdc, width, height);
|
|
return CreateCompatibleBitmap(hdc, width, height);
|
|
}
|
|
|
|
/***********************************************************************
|
|
* GetBitmapDimensionEx (GDI.468)
|
|
*/
|
|
BOOL GetBitmapDimensionEx( HBITMAP hbitmap, LPSIZE size )
|
|
{
|
|
BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
|
|
if (!bmp) return FALSE;
|
|
*size = bmp->size;
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetBitmapDimension (GDI.162)
|
|
*/
|
|
DWORD GetBitmapDimension( HBITMAP hbitmap )
|
|
{
|
|
SIZE size;
|
|
if (!GetBitmapDimensionEx( hbitmap, &size )) return 0;
|
|
return size.cx | (size.cy << 16);
|
|
}
|
|
|
|
/***********************************************************************
|
|
* SetBitmapDimensionEx (GDI.478)
|
|
*/
|
|
BOOL SetBitmapDimensionEx( HBITMAP hbitmap, short x, short y, LPSIZE prevSize )
|
|
{
|
|
BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
|
|
if (!bmp) return FALSE;
|
|
if (prevSize) *prevSize = bmp->size;
|
|
bmp->size.cx = x;
|
|
bmp->size.cy = y;
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* SetBitmapDimension (GDI.163)
|
|
*/
|
|
DWORD SetBitmapDimension( HBITMAP hbitmap, short x, short y )
|
|
{
|
|
SIZE size;
|
|
if (!SetBitmapDimensionEx( hbitmap, x, y, &size )) return 0;
|
|
return size.cx | (size.cy << 16);
|
|
}
|