[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 908
Date       : Thu Apr 27 12:40:38 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/sginit.cpp
   M /Trunk/XaraLX/wxOil/grndrgn.cpp
   M /Trunk/XaraLX/wxOil/grndrgn.h
   M /Trunk/XaraLX/wxOil/oilbitmap.cpp
   M /Trunk/XaraLX/wxOil/oilbitmap.h
   M /Trunk/XaraLX/wxOil/osrndrgn.cpp

Enabled the bitmap gallery.
Fixed OSRenderRegion::PlotTransformedBitmap, at least when not printing


Diff:
Index: Trunk/XaraLX/Kernel/sginit.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sginit.cpp	(revision 907)
+++ Trunk/XaraLX/Kernel/sginit.cpp	(revision 908)
@@ -195,9 +195,7 @@
 #ifndef EXCLUDE_FROM_XARALX
 				NewColourDlg::Init()				&&
 #endif
-#ifdef _DEBUG // For now bitmap gallery only on debug builds
 				OpDisplayBitmapGallery::Init()		&&
-#endif
 #ifndef EXCLUDE_FROM_XARALX
 				OpDisplayFontsGallery::Init()		&&
 #endif // EXCLUDE_FROM_XARALX
Index: Trunk/XaraLX/wxOil/grndrgn.h
===================================================================
--- Trunk/XaraLX/wxOil/grndrgn.h	(revision 907)
+++ Trunk/XaraLX/wxOil/grndrgn.h	(revision 908)
@@ -391,7 +391,9 @@
 
 	void PlotBitmap( UINT32 ColourFlag );
 	void PlotBitmap( wxDC *pDC, UINT32 ColourFlag, INT32 Left, INT32 Top, UINT32 Width, UINT32 Height, wxPalette* hPal, INT32, INT32 );
-
+public:
+	static LPBYTE StaticPlotBitmap( wxDC *pDC, UINT32 ColourFlag, LPBITMAPINFO lpBitmapInfo, LPBYTE lpBits, INT32 Left, INT32 Top, UINT32 Width, UINT32 Height, wxPalette* hPal, INT32, INT32 );
+protected:
 //	KernelBitmap* FractalBitmap;		// GAT: Never used.
 
 	// Limit of transparency in hit-detect pixels before pixel will be ignored
Index: Trunk/XaraLX/wxOil/oilbitmap.cpp
===================================================================
--- Trunk/XaraLX/wxOil/oilbitmap.cpp	(revision 907)
+++ Trunk/XaraLX/wxOil/oilbitmap.cpp	(revision 908)
@@ -2147,12 +2147,14 @@
 
 /********************************************************************************************
 
->	virtual wxImage * CWxBitmap::MakewxImage(BOOL UsePalette) const;
+>	virtual wxImage * CWxBitmap::MakewxImage(UINT32 ImageWidth=0, UINT32 ImageHeight=0, BOOL UsePalette=TRUE) const;
 
 	Author:		Alex Bligh
 	Created:	26/04/2006
 
-	Inputs:		UsePalette -Ignored for deep bitmaps
+	Inputs:		ImageWidth - Width of image to make (or zero for width of bitmap)
+				ImageHeight - Depth of image to make (or zero for depth of bitmap)
+				UsePalette -Ignored for deep bitmaps
 							For <=8bpp bitmaps, if this value is:
 								FALSE, the bitmap's palette will be ignored, and the actual pixel
 								(palette index) value will be returned as a greyscale RGB value
@@ -2174,25 +2176,46 @@
 
 ********************************************************************************************/
 
-wxImage * CWxBitmap::MakewxImage(BOOL UsePalette)
+wxImage * CWxBitmap::MakewxImage(UINT32 ImageWidth, UINT32 ImageHeight, BOOL UsePalette)
 {
+	if (!ImageWidth)
+		ImageWidth=GetWidth();
+	if (!ImageHeight)
+		ImageHeight=GetHeight();
+
 	wxImage * pImage = new wxImage(GetWidth(), GetHeight(), /*TYPENOTE: Correct*/ false);
 	if (!pImage)
 		return NULL;
+#if 0
 	pImage->SetAlpha();
 	if (!pImage->HasAlpha())
 	{
 		delete pImage;
 		return NULL;
 	}
+#endif
 
 	RebuildXPEBitmap();
 
-	for (UINT32 YPos = 0; YPos < GetHeight(); YPos++) for (UINT32 XPos = 0; XPos < GetWidth(); XPos++)
+	double xstep = GetWidth()/ImageWidth;
+	double ystep = GetHeight()/ImageHeight;
+	double x=0;
+	double y=0;
+
+	for (UINT32 YPos = 0; YPos < ImageHeight; YPos++)
 	{
-		Pixel32bpp p = ReadPixel32bpp(XPos, YPos, UsePalette);
-		pImage->SetRGB(XPos, YPos, p.Red, p.Blue, p.Green);
-		pImage->SetAlpha(XPos, YPos, 255-p.Alpha); // wxImage alpha has 0 for fully transparent
+		UINT32 YP=(UINT32)(y+0.5);
+		x=0;
+		for (UINT32 XPos = 0; XPos < ImageWidth; XPos++)
+		{
+			UINT32 XP=(UINT32)(x+0.5);
+			Pixel32bpp p = ReadPixel32bpp(XP, YP, UsePalette);
+			pImage->SetRGB(XPos, YPos, p.Red, p.Blue, p.Green);
+//			pImage->SetAlpha(XPos, YPos, 255-p.Alpha); // wxImage alpha has 0 for fully transparent
+
+			x+=xstep;
+		}
+		y+=ystep;
 	}
 
 	return(pImage);
Index: Trunk/XaraLX/wxOil/oilbitmap.h
===================================================================
--- Trunk/XaraLX/wxOil/oilbitmap.h	(revision 907)
+++ Trunk/XaraLX/wxOil/oilbitmap.h	(revision 908)
@@ -161,7 +161,7 @@
 	// Helper function used by ExportSeparatedData - this retrieves one scanline of the
 	// bitmap as generic 24bpp RGB data.
 	virtual BOOL GetScanline32bpp(UINT32 YPos, BOOL UsePalette, Pixel32bpp *Scanline);
-	virtual wxImage * MakewxImage(BOOL UsePalette=TRUE);
+	virtual wxImage * MakewxImage(UINT32 ImageWidth=0, UINT32 ImageHeight=0, BOOL UsePalette=TRUE);
 
 	virtual OILBitmap* MakeCopy(); // returns a copy of this object
 protected:
Index: Trunk/XaraLX/wxOil/grndrgn.cpp
===================================================================
--- Trunk/XaraLX/wxOil/grndrgn.cpp	(revision 907)
+++ Trunk/XaraLX/wxOil/grndrgn.cpp	(revision 908)
@@ -6350,13 +6350,20 @@
 void GRenderRegion::PlotBitmap( wxDC* hDC, UINT32 ColourFlag,
 		INT32 Left,INT32 Top, UINT32 Width,UINT32 Height, wxPalette* hPalette, INT32 SourceLeft,INT32 SourceTop )
 {
+	pBits=StaticPlotBitmap(hDC, ColourFlag, pBitmapInfo, pBits, Left, Top, Width, Height, hPalette, SourceLeft, SourceTop);
+}
+
+LPBYTE GRenderRegion::StaticPlotBitmap( wxDC* hDC, UINT32 ColourFlag,
+		LPBITMAPINFO lpBitmapInfo, LPBYTE lpBits,
+		INT32 Left,INT32 Top, UINT32 Width,UINT32 Height, wxPalette* hPalette, INT32 SourceLeft,INT32 SourceTop )
+{
 	if( Width==0 || Height==0 )
-		return;
+		return lpBits;
 
 	// Test preconditions
-	ERROR3IF((pBitmapInfo->bmiHeader.biSize==0x00000000) /*|| 
-			 (pBitmapInfo->bmiHeader.biSize==0xdddddddd) || 
-			 (pBitmapInfo->bmiHeader.biSize==0xcdcdcdcd) */,"Illegal BitmapInfo structure passed to PlotBitmap");
+	ERROR3IF((lpBitmapInfo->bmiHeader.biSize==0x00000000) /*|| 
+			 (lpBitmapInfo->bmiHeader.biSize==0xdddddddd) || 
+			 (lpBitmapInfo->bmiHeader.biSize==0xcdcdcdcd) */,"Illegal BitmapInfo structure passed to PlotBitmap");
 			// AB commented second two checks out as bmiHeader.biSize is a WORD, i.e. 16 bits in size, according to compatdef.h
 //	TRACE( _T("SrcRect(%d, %d, %d, %d) - (%d, %d)"), rectDraw.GetLeft(), rectDraw.GetTop(),
 //		rectDraw.GetWidth(), rectDraw.GetHeight(), pBitmap->GetWidth(), pBitmap->GetHeight() );
@@ -6365,7 +6372,7 @@
 
 #if !USE_wxBITMAP
 
-	ERROR3IF(pBitmapInfo->bmiHeader.biBitCount!=32,"Image must (currently) be 32bpp");
+	ERROR3IF(lpBitmapInfo->bmiHeader.biBitCount!=32,"Image must (currently) be 32bpp");
 
 	wxBitmap Bitmap(Width,Height,32);
 	wxAlphaPixelData BitmapData(Bitmap);
@@ -6373,8 +6380,8 @@
 	// Copy source (or part of source) into wxBitmap.
 	//
 	DWORD* pSBuffer = 
-			(DWORD*)pBits + 
-			pBitmapInfo->bmiHeader.biWidth*(pBitmapInfo->bmiHeader.biHeight-1-SourceTop) +
+			(DWORD*)lpBits + 
+			lpBitmapInfo->bmiHeader.biWidth*(lpBitmapInfo->bmiHeader.biHeight-1-SourceTop) +
 			SourceLeft;
 	DWORD* pDBuffer = (DWORD*)Bitmap.GetRawData(BitmapData,32);
 	DWORD* pDLine = pDBuffer;
@@ -6394,7 +6401,7 @@
 #else
 			pDLine[x] = pSBuffer[x];
 #endif
-		pSBuffer -= pBitmapInfo->bmiHeader.biWidth;
+		pSBuffer -= lpBitmapInfo->bmiHeader.biWidth;
 		pDLine += nStep;
 	}
 	if ( ScreenHinting==CONVHINT_FINAL16  ||
@@ -6438,7 +6445,7 @@
 #else
 
 #if defined(__WXGTK__)
-	RGBT* pBuffer = (RGBT*)pBits + pBitmapData->m_width*SourceTop + SourceLeft;
+	RGBT* pBuffer = (RGBT*)lpBits + pBitmapData->m_width*SourceTop + SourceLeft;
 	for( UINT32 y=0 ; y<Height ; ++y )
 	{
 		//
@@ -6493,7 +6500,7 @@
 	else
 	{
 		if ( bIs16Bit )
-			GRenderRegion::GetStaticDrawContext()->ConvertBitmap(&Info,pBits,&Info,pBits,uHint);
+			GRenderRegion::GetStaticDrawContext()->ConvertBitmap(&Info,lpBits,&Info,lpBits,uHint);
 		pBitmap->UngetRawData(*pBitmapData) ;
 		{
 //			CamProfile cp(CAMPROFILE_BLIT);
@@ -6502,9 +6509,9 @@
 		TRACE( _T("DrawBitmap(%08x,%04x,%04x)
"),hDC,Left,Top);
 	}
 
-	pBits = (BYTE*)pBitmap->GetRawData(*pBitmapData,uBitmapDepth);
-
+	lpBits = (BYTE*)pBitmap->GetRawData(*pBitmapData,uBitmapDepth);
 #endif
+	return lpBits;
 }
 
 
Index: Trunk/XaraLX/wxOil/osrndrgn.cpp
===================================================================
--- Trunk/XaraLX/wxOil/osrndrgn.cpp	(revision 907)
+++ Trunk/XaraLX/wxOil/osrndrgn.cpp	(revision 908)
@@ -144,7 +144,7 @@
 // #include "metaview.h"
 #include "gradtbl.h"
 #include "unicdman.h"  // For MBCS support
-// #include "mrhbits.h"
+#include "mrhbits.h"
 #include "strkattr.h"
 #include "cartprov.h"
 
@@ -3431,13 +3431,13 @@
 				// Get handle to bitmap (must be a WinBitmap as we are in winoil!)
 				CWxBitmap *WxBM = (CWxBitmap *) pNodeBitmap->GetBitmap()->ActualBitmap;
 
-				wxImage *pwxImage=WxBM->MakewxImage();
+				wxImage *pwxImage=WxBM->MakewxImage(DestWidth, DestHeight);
 
 				if (pwxImage)
 				{
-					wxBitmap TheBitmap(pwxImage->Rescale(DestWidth, DestHeight));
+					wxBitmap TheBitmap(pwxImage);
+					RenderDC->DrawBitmap(TheBitmap, DestTopLeft.x, DestTopLeft.y, TRUE);
 					delete pwxImage;
-					RenderDC->DrawBitmap(TheBitmap, DestTopLeft.x, DestTopLeft.y, TRUE);
 				}
 			}
 		}
@@ -4293,8 +4293,6 @@
 
 BOOL OSRenderRegion::RenderBitmapFill(Path *PathToDraw, BitmapFillAttribute* Fill)
 {
-	PORTNOTETRACE("other","OSRenderRegion::RenderBitmapFill - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
 	if (Fill->GetBitmap() == NULL || Fill->GetBitmap()->ActualBitmap == NULL)
 		return FALSE;									// if no bitmap
 
@@ -4303,15 +4301,15 @@
 	if ((RenderFlags.VeryMono) || (RFlags.Metafile))
 		return FALSE;
 
-	ENSURE( Fill->GetBitmap()->ActualBitmap->IsKindOf( CC_RUNTIME_CLASS( WinBitmap ) ), "Strange bitmapfill");
+	ENSURE( Fill->GetBitmap()->ActualBitmap->IsKindOf( CC_RUNTIME_CLASS( CWxBitmap ) ), "Strange bitmapfill");
 
 // Since the GDI cannot cope with anything other than very simple bitmaps,
 // we will get GDraw to render the bitmap into a screen compatible DIB, and
 // then get the GDI to plot that
 
 	GDrawContext* GD = GRenderRegion::GetStaticDrawContext();
-	WinBitmap *WinBM = NULL;
-	WinBitmap *OrigWinBM = NULL;
+	CWxBitmap *WxBM = NULL;
+	CWxBitmap *OrigWxBM = NULL;
 
 	const INT32 bpp = Fill->GetBitmap()->GetBPP();
 	BYTE *pGreyTable = NULL;
@@ -4319,9 +4317,9 @@
 	if (Fill->GetStartColour() != NULL && Fill->GetEndColour() != NULL)
 	{
 		// The bitmap is contoned ... so we need to use the greyscale version
-		WinBM = (WinBitmap*)Fill->GetBitmap()->GetGreyscaleVersion();
+		WxBM = (CWxBitmap*)Fill->GetBitmap()->GetGreyscaleVersion();
 
-		if (WinBM == NULL && bpp == 8)
+		if (WxBM == NULL && bpp == 8)
 		{
 			// Aha, we're gunna do some clever palette jiggery pokery
 			pGreyTable = Fill->GetBitmap()->ActualBitmap->GetGreyscaleTable();
@@ -4331,24 +4329,24 @@
 	// Now make sure that if the WinBitmap is 32 that we RENDER it into a tempory FULLY TRANSPARENT WHITE BMP.
 	// This stops the CONVERT function later on stripping the alpha channel off producing solid, non-transparent
 	// coloured objects on black black backgrounds! - MarkH 20/7/99.
-	if (WinBM == NULL)
+	if (WxBM == NULL)
 	{
 		if (bpp != 32)
 		{
-			WinBM = (WinBitmap*)Fill->GetBitmap()->ActualBitmap;
+			WxBM = (CWxBitmap*)Fill->GetBitmap()->ActualBitmap;
 		}
 		else
 		{
-			WinBM = (WinBitmap*)CBMPBits::RenderBMPFillAttrToTransparentWhiteRect(Fill);
+			WxBM = (CWxBitmap*)CBMPBits::RenderBMPFillAttrToTransparentWhiteRect(Fill);
 		}
 	}
 
-	if (!WinBM)				// we really should check this pointer!
+	if (!WxBM)				// we really should check this pointer!
 	{
 		return (FALSE);
 	}
 
-	if( (WinBM->BMInfo==NULL) || (WinBM->BMBytes==NULL) )
+	if( (WxBM->BMInfo==NULL) || (WxBM->BMBytes==NULL) )
 		return FALSE;
 
 	// Work out what Tempory bitmap we need
@@ -4372,8 +4370,10 @@
 		if (CurrentColContext->GetColourPlate() == NULL ||
 			CurrentColContext->GetColourPlate()->IsDisabled())
 		{
+PORTNOTE("other", "No StretchDIBits call in OSRenderRegion::RenderBitmapFill")
+#ifndef EXCLUDE_FROM_XARALX
 			// going to a printer? - let its driver stretch it about etc
-			const LPBITMAPINFO bmInfo = WinBM->BMInfo;
+			const LPBITMAPINFO bmInfo = WxBM->BMInfo;
 
 			#if 1
 			// this is the correct legit code
@@ -4401,6 +4401,7 @@
 
 				return TRUE;
 			}
+#endif
 
 			// if 16- or 32-bit, leave for later. We get Gavin to scale it to an output bitmap
 			// then PlotDeepDIB it. Sadly, this requires serious amounts of RAM, so is prone
@@ -4436,8 +4437,13 @@
 	}
 	else
 	{
+PORTNOTE("other", "Assume 24 bit output device in OSRenderRegion::RenderBitmapFill")
+#ifndef EXCLUDE_FROM_XARALX
 		DeviceDepth = GetDeviceCaps( RenderDC->m_hDC, BITSPIXEL ) * 
 										GetDeviceCaps( RenderDC->m_hDC, PLANES );
+#else
+		DeviceDepth=24; // assume true colour
+#endif
 
 		if (DeviceDepth ==24)
 			DeviceDepth = 32;	// GDraw cannot plot to 24-bit bitmaps
@@ -4476,7 +4482,7 @@
 
 	// Do the colour correction. This may produce a new pointer in Palette or BitmapBits,
 	// which we should CCFree() when we are done with it - see the end of this function
-	ColourCorrectBitmap(Fill, WinBM->BMInfo, &Palette);
+	ColourCorrectBitmap(Fill, WxBM->BMInfo, &Palette);
 
 	// Now see if we need to muck around with the palette for the contoning
 	if (pGreyTable != NULL)
@@ -4499,13 +4505,13 @@
 			Palette[i] = OldPalette[pGreyTable[i]];
 		}
 
-		if (OldPalette != WinBM->BMInfo->bmiColors)
+		if (OldPalette != WxBM->BMInfo->bmiColors)
 			CCFree(OldPalette);			// Don't need the contone palette any more
 	}
 
 	// If we didn't create a temporary palette, then we'll use the original bitmap
 	if (Palette == NULL)
-		Palette = WinBM->BMInfo->bmiColors;
+		Palette = WxBM->BMInfo->bmiColors;
 
 	// Search for a transparent colour setting the Style flags if necessary...
 	if (bpp <= 8)
@@ -4565,7 +4571,6 @@
 
 	DWORD Style = 1;
 	BOOL bDoBitmapFill = TRUE;
-	DWORD* pConvTable = NULL;
 	BYTE* pSepTables = NULL;
 	BGR *pCyanSepTable = NULL;
 	BGR *pMagentaSepTable = NULL;
@@ -4573,8 +4578,10 @@
 	BGR *pBlackSepTable = NULL;
 	BYTE *pUnderColourRemovalTable = NULL;
 	BYTE *pBlackGenerationTable = NULL;
-	WinBitmap* pNewBitmap = NULL;
+	CWxBitmap* pNewBitmap = NULL;
 	
+PORTNOTE("other", "No colour separation OSRenderRegion::RenderBitmapFill")
+#ifndef EXCLUDE_FROM_XARALX
 	// --- Add Separation Style bits as approriate to the current colour separation mode
 	if (bpp > 8)	// Only needed for deep bitmaps
 	{
@@ -4605,20 +4612,20 @@
 					if (cc->GetProfileTables(pSepTables))
 					{
 						// Make a copy of the bitmap
-						pNewBitmap = (WinBitmap*)WinBM->MakeSeparatedCopy(RenderView->GetColourPlate(), pSepTables);
-						OrigWinBM = WinBM;					// Save original bitmap pointer
-						WinBM = pNewBitmap;					// Use this bitmap instead
+						pNewBitmap = (CWxBitmap*)WxBM->MakeSeparatedCopy(RenderView->GetColourPlate(), pSepTables);
+						OrigWxBM = WxBM;					// Save original bitmap pointer
+						WxBM = pNewBitmap;					// Use this bitmap instead
 					}
 					delete cc;
 				}
 			}
 		}
 	}
-
+#endif
 	if (bDoBitmapFill)
 	{
-		GD->SetBitmapFill(	&(WinBM->BMInfo->bmiHeader),
-							WinBM->BMBytes,
+		GD->SetBitmapFill(	&(WxBM->BMInfo->bmiHeader),
+							WxBM->BMBytes,
 							Style,
 							PGram,
 							DefaultColour,
@@ -4646,7 +4653,7 @@
 		// into a 32-bit one, so send it out
 
 		// PlotDeepDIB ends up doing a SetDIBitsToDevice in 24-bit slices
-		DIBUtil::PlotDeepDIB( RenderDC->m_hDC, TempInfo, TempBits, 
+		DIBUtil::PlotDeepDIB( RenderDC, TempInfo, TempBits, 
 							BottomLeft.x, TopLeft.y,
 							DestWidth,DestHeight,
 							0,0, 
@@ -4655,15 +4662,15 @@
 	else
 	{
 		// get the HPALETTE to pass to the plot bitmap call - crucial for quality Win32s DDB plotting
-		HPALETTE hPal = NULL;
+		wxPalette * hPal = NULL;
 		if (RFlags.UsePalette)
-			hPal = *(PaletteManager::GetPalette());		// Sneaky HPALETTE operator
+			hPal = PaletteManager::GetPalette();
 
 		// Finally call PlotBitmap, to render the DIB using the GDI.
 		// If the screen cannot cope with the depth of the bitmap, it will be converted
 		// for us. Isn't PlotBitmap wonderful?
 
-		GRenderRegion::PlotBitmap( 	RenderDC->m_hDC, 
+		GRenderRegion::StaticPlotBitmap( RenderDC, 
 								DIBPal, 
 								TempInfo, 
 								TempBits,
@@ -4680,14 +4687,14 @@
 
 	if (pNewBitmap)
 	{
-		WinBM = OrigWinBM;
+		WxBM = OrigWxBM;
 		delete pNewBitmap;
 	}
 
 	// Free any memory used for colour-corrected bitmap palettes.
 	// If this pointer doesn't point at the original palette, then it has
 	// been temporarily allocated by ColourCorrectBitmap, above.
-	if (Palette != WinBM->BMInfo->bmiColors)
+	if (Palette != WxBM->BMInfo->bmiColors)
 		CCFree(Palette);
 	
 	if (pSepTables)
@@ -4708,7 +4715,7 @@
 		CCFree(pUnderColourRemovalTable);
 	if (pBlackGenerationTable)
 		CCFree(pBlackGenerationTable);
-#endif
+
    	return TRUE;
 }
 


Xara