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

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 1225
Date       : Wed May 31 13:55:07 BST 2006

Changed paths:
   M /Trunk/XaraLX/wxOil/oilbitmap.cpp
   M /Trunk/XaraLX/wxOil/oilbitmap.h

Fix colour editor 3D controls


Diff:
Index: Trunk/XaraLX/wxOil/oilbitmap.cpp
===================================================================
--- Trunk/XaraLX/wxOil/oilbitmap.cpp	(revision 1224)
+++ Trunk/XaraLX/wxOil/oilbitmap.cpp	(revision 1225)
@@ -103,6 +103,7 @@
 
 #include "camtypes.h"
 
+#include "cartprov.h"
 #include "oilbitmap.h"
 #include "ccfile.h"
 #include "dibutil.h"
@@ -3705,33 +3706,60 @@
 
 BOOL CWxBitmap::LoadBitmap(UINT32 BitmapResourceID)
 {
-	PORTNOTETRACE("other","CWxBitmap::LoadBitmap - do nothing");
-#ifndef EXCLUDE_FROM_XARALX
-	CCResourceFile *ResFile = new CCResourceFile;
-	if (ResFile == NULL)
+	wxBitmap * pBitmap=CamArtProvider::Get()->FindBitmap((ResourceID)BitmapResourceID);
+	if (!pBitmap)
 		return FALSE;
 
-	if (!ResFile->open( MAKEINTRESOURCE(BitmapResourceID), RT_BITMAP ))
-	{
-		delete ResFile;
+	return CreateFromwxBitmap(pBitmap);
+}
+
+BOOL CWxBitmap::CreateFromwxBitmap(wxBitmap * pBitmap)
+{
+	wxImage i = pBitmap->ConvertToImage();
+	return CreateFromwxImage(&i);
+}
+
+BOOL CWxBitmap::CreateFromwxImage(wxImage * pImage)
+{
+	LPBITMAPINFO bmInfo;
+	LPBYTE bmBytes;
+
+	bmInfo = AllocDIB( pImage->GetWidth(), pImage->GetHeight(), 32, &bmBytes );
+	if (!bmInfo || !bmBytes)
 		return FALSE;
-	}
 
-	ResFile->SetReportErrors(FALSE);
+	BMInfo=bmInfo;
+	BMBytes=bmBytes;
 
-	BOOL ReadOK = DIBUtil::ReadFromFile( ResFile, &BMInfo, &BMBytes, FALSE );
-		
-	// close file regardless
-	if (ResFile->isOpen())
-		ResFile->close();
+	INT32 dpi=96;
 
-	// and delete it
-	delete ResFile;
+	double xppm = ((double)dpi * 10000.0)/254.0;
+	bmInfo->bmiHeader.biXPelsPerMeter = (INT32)(xppm + 0.5);
+	bmInfo->bmiHeader.biYPelsPerMeter = bmInfo->bmiHeader.biXPelsPerMeter;
 
-	return ReadOK;
-#else
-	return FALSE;
-#endif
+	CacheGeometry();
+
+	unsigned char * pData=pImage->GetData();
+	unsigned char * pAlpha=NULL;
+	if (pImage->HasAlpha())
+		pAlpha=pImage->GetAlpha();
+
+	// Reasonably rapid conversion to internal format
+	for (UINT32 YPos = 0; YPos < GetHeight(); YPos++)
+	{
+		BYTE *ScanlineStart = BMBytes + (YPos * ScanLineByteWidth);
+		INT32 off=0;
+
+		for (UINT32 XPos = 0; XPos < GetWidth(); XPos++)
+		{
+			ScanlineStart[off++] = *(pData++); //Red
+			ScanlineStart[off++] = *(pData++); //Green
+			ScanlineStart[off++] = *(pData++); //Blue
+			ScanlineStart[off++] = pAlpha?(255-*(pAlpha++)):0; // Alpha
+		}
+	}
+
+	return TRUE;
 }
 
 /********************************************************************************************
Index: Trunk/XaraLX/wxOil/oilbitmap.h
===================================================================
--- Trunk/XaraLX/wxOil/oilbitmap.h	(revision 1224)
+++ Trunk/XaraLX/wxOil/oilbitmap.h	(revision 1225)
@@ -203,6 +203,8 @@
 	virtual BOOL ImportBitmap(Filter*, const BitmapInfo*, INT32);
 
  	virtual BOOL LoadBitmap(UINT32 BitmapResourceID);
+	virtual BOOL CreateFromwxBitmap(wxBitmap * pBitmap);
+	virtual BOOL CreateFromwxImage(wxImage * pImage);
 
 	virtual BOOL GetPaletteUsage(INT32 *);
 	virtual BOOL PrepareMask(INT32 PaletteEntry);


Xara