abstractimage.cpp

来自「这是VCF框架的代码」· C++ 代码 · 共 255 行

CPP
255
字号
//AbstractImage.cpp/*Copyright 2000-2004 The VCF Project.Please see License.txt in the top level directorywhere you installed the VCF.*//* Generated by Together */#include "vcf/GraphicsKit/GraphicsKit.h"using namespace VCF;AbstractImage::AbstractImage( const bool& needsMemAlloc ):		imageBits_(NULL),	dataBuffer_(NULL),	height_(0),	width_(0),		context_(NULL),	isTransparent_(false),	needsMemAlloc_(needsMemAlloc){	imageBits_ = new ImageBits(0,0,needsMemAlloc);	}AbstractImage::~AbstractImage(){	delete context_;	delete imageBits_;}void AbstractImage::setSize(const unsigned long & width, const unsigned long & height ){	width_ = width;	height_ = height;	if ( (width_ > 0) && (height_ > 0) ) {		imageBits_->allocatePixelMemory( width_, height_ );		ImageEvent event(this);		event.setType( IMAGE_EVENT_WIDTH_CHANGED );		event.setNewWidth( width );		ImageSizeChanged.fireEvent( &event );		ImageEvent event2(this);		event2.setType( IMAGE_EVENT_HEIGHT_CHANGED );		event2.setNewHeight( height_ );		ImageSizeChanged.fireEvent( &event2 );	}}unsigned long AbstractImage::getWidth(){	return width_;}unsigned long AbstractImage::getHeight(){	return height_;}GraphicsContext* AbstractImage::getImageContext(){	return context_;}ImageBits* AbstractImage::getImageBits(){	return imageBits_;}void AbstractImage::saveToStream( OutputStream * stream ){	long bitDepth = getType() * getChannelSize();	stream->write( bitDepth );	stream->write( (long)height_ );	stream->write( (long)width_ );	const unsigned char* buffer = (const unsigned char*)imageBits_->pixels_;	stream->write( buffer, height_ * width_ * getType() );}void AbstractImage::loadFromStream( InputStream * stream ){	long bitDepth;	stream->read( bitDepth );	long height = 0;	long width = 0;	stream->read( height );	stream->read( width );	setSize( width, height );	unsigned char* buffer = (unsigned char*)imageBits_->pixels_;	stream->read( buffer, height_ * width_ * getType() );}Image::ImageType AbstractImage::getType() const{	return IMTRAITS::getImageType( flags_ );}Image::ImageChannelSize AbstractImage::getChannelSize() const{	return IMTRAITS::getChannelSize( flags_ );}Image::ImageChannelType AbstractImage::getChannelType() const{	return IMTRAITS::getChannelType( flags_ );}Image::PixelLayoutOrder AbstractImage::getPixelLayoutOrder() const{	return IMTRAITS::getPixelLayoutOrder( flags_ );}void* AbstractImage::getData(){	dataBuffer_ = (unsigned char*)imageBits_->pixels_;	return dataBuffer_;}/***CVS Log info*$Log$*Revision 1.3  2006/04/07 02:35:41  ddiego*initial checkin of merge from 0.6.9 dev branch.**Revision 1.2.6.4  2005/11/10 02:02:39  ddiego*updated the osx build so that it*compiles again on xcode 1.5. this applies to the foundationkit and graphicskit.**Revision 1.2.6.3  2005/10/17 01:36:34  ddiego*some more under the hood image stuff. updated agg.**Revision 1.2.6.2  2005/10/11 00:54:51  ddiego*added initial changes for grayscale image support. fixed some minor changes to form loading and creating.**Revision 1.2.6.1  2005/09/21 02:21:53  ddiego*started to integrate jpeg support directly into graphicskit.**Revision 1.2  2004/08/07 02:49:16  ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.3  2004/08/01 18:52:27  kiklop74*A bit ugly workaround around BCB5 bugs during compilation**Revision 1.1.2.2  2004/04/29 04:10:26  marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.1  2004/04/28 03:40:30  ddiego*migration towards new directory structure**Revision 1.20  2003/08/09 02:56:45  ddiego*merge over from the devmain-0-6-1 branch*Changes*Features:*-Added additional implementation to better support the MVC architecture in*the VCF**-Added a Document/View architecure that is similar to MFC's or NextSteps's*Doc/View architectures**-Integrated the Anti Grain Graphics library into the GraphicsKit. There is*now basic support for it in terms of drawing vector shapes*(fills and strokes). Image support will come in the next release**-Added several documented graphics tutorials**Bugfixes:**[ 775744 ] wrong buttons on a dialog*[ 585239 ] Painting weirdness in a modal dialog ?*[ 585238 ] Modal dialog which makes a modal Dialog*[ 509004 ] Opening a modal Dialog causes flicker*[ 524878 ] onDropped not called for MLTcontrol**Plus an issue with some focus and getting the right popup window to activate*has also been fixed**Revision 1.19.2.1  2003/06/16 03:09:39  ddiego*beginning to add support for AGG into the VCF GraphicsKit*added some missing files*added some changes to the new version of xmake**Revision 1.19  2003/05/17 20:37:19  ddiego*this is the checkin for the 0.6.1 release - represents the merge over from*the devmain-0-6-0 branch plus a few minor bug fixes**Revision 1.18.2.3  2003/04/07 03:39:31  ddiego*did some documentation work, and got everything to compile cleanly with some*of the new additions, particularly the chnages inteh Image/ImageBits classes.**Revision 1.18.2.2  2003/03/23 03:23:55  marcelloptr*3 empty lines at the end of the files**Revision 1.18.2.1  2003/03/12 03:11:58  ddiego*switched all member variable that used the "m_"<name> prefix to* <name>"_" suffix nameing standard.*Also changed all vcf builder files to accomadate this.*Changes were made to the Stream classes to NOT multiple inheritance and to*be a little more correct. Changes include breaking the FileStream into two*distinct classes, one for input and one for output.**Revision 1.18  2003/02/26 04:30:45  ddiego*merge of code in the devmain-0-5-9 branch into the current tree.*most additions are in the area of the current linux port, but the major*addition to this release is the addition of a Condition class (currently*still under development) and the change over to using the Delegate class*exclusively from the older event handler macros.**Revision 1.17.8.1  2003/02/24 05:42:18  ddiego*moved the code for the VariantData calss into it's own header*migrated to the new event style using Delegates instead of relying on*the ugly macros that we were using before - same functionality though*made sure everything still works and compiles, including neccessary*changes in the VCF Builder so that it creates code in the new style*This changes to teh new style of using Delegates completes task 58837**Revision 1.17  2002/09/12 03:26:05  ddiego*merged over the changes from the devmain-0-5-5b branch**Revision 1.16.6.1  2002/08/06 02:57:36  ddiego*added base X11 files for GraphicsKit and made sure that the GraphicsKit compiles*under linux (GCC). There is now a new dir under build/xmake called GraphicsKit*where the xmake build script lives. This checkin also includes the base X11*include (as part of GraphicsKitPrivate.h), as well as linking to the X11 libs**Revision 1.16  2002/05/09 03:10:44  ddiego*merged over code from development branch devmain-0-5-1a into the main CVS trunk**Revision 1.15.4.1  2002/04/03 19:37:17  zzack*include style changed**Revision 1.15  2002/01/29 04:41:43  ddiego*fixed leak in Win32Button, plus cleaned up some other GetDC stuff and*fixed the Tab problem in Win98.**Revision 1.14  2002/01/24 01:46:49  ddiego*added a cvs "log" comment to the top of all files in vcf/src and vcf/include*to facilitate change tracking**/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?