![]() |
The memory device classHow to create the memory device classIt is possible to operate the data of the image directly by the memory device class. The memory device has the following facilities.![]() ![]() ![]() [The sample which indicates the image gradually.] This sample does the following. #include <WScom.h> #include <WSCfunctionList.h> #include <WSCbase.h> //---------------------------------------------------------- //Function for the event procedure //---------------------------------------------------------- #include <WSDappDev.h> #include <WSCcolorSet.h> #include <WSCimageSet.h> #include <WSCmainWindow.h> extern WSCmainWindow* newwin000; #include <WSDmwindowDev.h> WSDmwindowDev* mdev = NULL; WSDmwindowDev* mdev2 = NULL; void btnep(WSCbase* object){ WSDdev* dev = newwin000->getdev(); //A if (mdev == NULL){ //B mdev = WSDmwindowDev::getNewInstance(); mdev2 = WSDmwindowDev::getNewInstance(); } mdev->createPixmap(200,200); //C mdev->beginDraw(0,0,200,200); //D WSDimage* image = WSGIappImageSet()->getImage("001.jpg"); //E mdev->drawStretchedImage(0,0,200,200,image); //F mdev->endDraw(); //G mdev2->createPixmap(200,200); //H mdev->initBuffer(); //I mdev2->initBuffer(); //J long i,x,y; for(i=0;i<100; i++){ for(x=0; x<200; x++){ for(y=0; y<200; y++){ WSCuchar r,g,b; mdev->getBufferRGB(x,y,&r,&g,&b); //K r = (WSCushort)((double)(r*i)/100); //L g = (WSCushort)((double)(g*i)/100); //L b = (WSCushort)((double)(b*i)/100); //L mdev2->setBufferRGB(x,y,r,g,b); //M } } mdev2->putBufferToPixmap(); //N mdev2->copyToWindow(dev,0,0,200,200,0,0); //P } } static WSCfunctionRegister op("btnep",(void*)btnep);It acquires the window device from the instance at (A) and creates the memory devices at the first click by the method: getNewInstance which creates an appropriate instance(B). It is impossible with new operator to create an instancde of the memory device class, because this class depends the window system. About indicating the image 001.jpg to mdev1, at first,initialize mdev1 by the method: createPixmap with the geometry (C). To begin draw pictures,call the method: beginDraw() of the device class(D). Aquire the image instance from the global image management class(E) and put the image instance to the memory device(F). If drawing pictures is over,call the method: endDraw(). Initialize mdev2 too at (H). and initialize the memory buffer for direct operation (I)(J),this time it transfers the internal image data on the frame buffer to the memory buffer. At(K), get the RGB value from mdev1. At(L), increase the brightness of the RGB value and set it to mdev2 (M). It transfers the memory data to the frame buffer(N). and indicates it by transfering to window(P). Document Release 3.0 For Use with Wide Studio Release 3.0, Summer 2002
|