Beispiel #1
0
void CtrlTree::onUpdate( Subject<VarTree, tree_update> &rTree,
                         tree_update *arg )
{
    if( arg->type == arg->UpdateItem ) // Item update
    {
        if( arg->b_active_item )
            autoScroll();
        if( isItemVisible( arg->i_id ) )
        {
            makeImage();
            notifyLayout();
        }
    }
    else if ( arg->type == arg->ResetAll ) // Global change or deletion
    {
        m_firstPos = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();

        makeImage();
        notifyLayout();
    }
    else if ( arg->type == arg->AppendItem ) // Item-append
    {
        if( m_flat && m_firstPos->size() )
        {
            m_firstPos = m_rTree.getNextLeaf( m_firstPos );

            makeImage();
            notifyLayout();
        }
        else if( isItemVisible( arg->i_id ) )
        {
            makeImage();
            notifyLayout();
        }
    }
    else if( arg->type == arg->DeleteItem ) // item-del
    {
        /* Make sure firstPos is valid */
        VarTree::Iterator it_old = m_firstPos;
        while( m_firstPos->isDeleted() &&
               m_firstPos != (m_flat ? m_rTree.firstLeaf()
                                     : m_rTree.begin()) )
        {
            m_firstPos = m_flat ? m_rTree.getPrevLeaf( m_firstPos )
                                : m_rTree.getPrevVisibleItem( m_firstPos );
        }
        if( m_firstPos->isDeleted() )
            m_firstPos = m_rTree.begin();

        if( m_firstPos != it_old || isItemVisible( arg->i_id ) )
        {
            makeImage();
            notifyLayout();
        }
    }
}
Beispiel #2
0
void CtrlTree::onUpdate( Subject<VarTree, tree_update> &rTree,
                         tree_update *arg )
{
    if( arg->i_type == 0 ) // Item update
    {
        if( arg->b_active_item )
        {
            autoScroll();
            ///\todo We should make image if we are visible in the view
            makeImage();
        }
    }
    /// \todo handle delete in a more clever way
    else if ( arg->i_type == 1 ) // Global change or deletion
    {
        m_firstPos = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();
        makeImage();
    }
    else if ( arg->i_type == 2 ) // Item-append
    {
        if( m_flat && m_firstPos->size() )
            m_firstPos = m_rTree.getNextLeaf( m_firstPos );
        /// \todo Check if the item is really visible in the view
        // (we only check if it in the document)
        if( arg->b_visible == true )
        {
            makeImage();
        }
    }
    else if( arg->i_type == 3 ) // item-del
    {
        /* Make sure firstPos and lastSelected are still valid */
        while( m_firstPos->m_deleted && m_firstPos != m_rTree.root()->begin() )
        {
            m_firstPos = m_flat ? m_rTree.getPrevLeaf( m_firstPos )
                                : m_rTree.getPrevVisibleItem( m_firstPos );
        }
        if( m_firstPos->m_deleted )
            m_firstPos = m_flat ? m_rTree.firstLeaf()
                                : m_rTree.root()->begin();

        if( arg->b_visible == true )
        {
            makeImage();
        }
    }
    notifyLayout();
}
Beispiel #3
0
/** @brief Creates a random image and uses it to test the 24-bit validation
 * 		   check.
 *
 *  This driver creates a random image with a bit depth value different
 *  than 24, simulating a not 24-bit bitmap image.
 *
 *  @return EXPECTED when everything goes as expected, else UNEXPECTED.
 */
PRIVATE int isPixel24bit() {

	char *fn_ip = "test_isPixel24bit.bmp";

	BITMAPFILEHEADER f_head;
	BITMAPINFOHEADER i_head;

	makeFileH('B', 'M', &f_head);
	makeInfoH(4, 2, 64, 0, &i_head);

	makeImage(fn_ip, f_head, i_head);

	printf("<isPixel24bit>\n");
	if(list(fn_ip)) {
		printf("</isPixel24bit>\n\n");
		if(remove(fn_ip)) {
			printf("**Error, isPixel24bit() driver unable to remove %s**",fn_ip);
			return UNEXPECTED;
		}
		return EXPECTED;
	}

	if(remove(fn_ip)) {
		printf("**Error, isPixel24bit() driver unable to remove %s**", fn_ip);
		return UNEXPECTED;
	}

	return UNEXPECTED;
}
Beispiel #4
0
/** @brief Creates a random image and uses it to test the compression validation
 * 		   check.
 *
 *  This driver creates a random image with a biCompression value different
 *  than 0, simulating a compressed bitmap image.
 *
 *  @return EXPECTED when everything goes as expected, else UNEXPECTED.
 */
PRIVATE int hasCompress() {

	char *fn_hc = "test_hasCompress.bmp";

	BITMAPFILEHEADER f_head;
	BITMAPINFOHEADER i_head;

	makeFileH('B', 'M', &f_head);
	makeInfoH(4, 2, 24, 5, &i_head);

	makeImage(fn_hc, f_head, i_head);

	printf("<hasCompress()>\n");
	if(list(fn_hc)) {
		printf("</hasCompress()>\n\n");
		if(remove(fn_hc)) {
			printf("**Error, hasCompress() driver unable to remove %s**",fn_hc);
			return UNEXPECTED;
		}
		return EXPECTED;
	}

	if(remove(fn_hc)) {
		printf("**Error, hasCompress() driver unable to remove %s**",fn_hc);
		return UNEXPECTED;
	}

	return UNEXPECTED;
}
Beispiel #5
0
/** @brief Creates a random image and uses it to test the bitmap type
 *         validation check.
 *
 *  This driver creates a random image with a type of file different than
 *  BM to simulate a non bitmap file.
 *
 *  @return EXPECTED when everything goes as expected, else UNEXPECTED.
 */
PRIVATE int isBM() {

	char *fn_ib = "test_isBM.bmp";

	BITMAPFILEHEADER f_head;
	BITMAPINFOHEADER i_head;

	makeFileH('O', 'K', &f_head);
	makeInfoH(4, 2, 24, 0, &i_head);

	makeImage(fn_ib, f_head, i_head);

	printf("<isBM()>\n");
	if(list(fn_ib)) {
		printf("</isBM()>\n\n");
		if(remove(fn_ib)) {
			printf("**Error, isBM() driver unable to remove %s**", fn_ib);
			return UNEXPECTED;
		}
		return EXPECTED;
	}

	if(remove(fn_ib)) {
		printf("**Error, isBM() driver unable to remove %s**", fn_ib);
		return UNEXPECTED;
	}

	return UNEXPECTED;
}
Beispiel #6
0
void TEWidget::propagateSize()
{
  ca* oldimg = image;
  int oldlin = lines;
  int oldcol = columns;
  makeImage();
  // we copy the old image to reduce flicker
  int lins = min(oldlin,lines);
  int cols = min(oldcol,columns);
  if (oldimg)
  {
    for (int lin = 0; lin < lins; lin++)
      memcpy((void*)&image[columns*lin],
             (void*)&oldimg[oldcol*lin],cols*sizeof(ca));
    free(oldimg); //FIXME: try new,delete
  }
  else
    clearImage();

  //NOTE: control flows from the back through the chest right into the eye.
  //      `emu' will call back via `setImage'.

  resizing = TRUE;
  emit changedImageSizeSignal(lines, columns); // expose resizeEvent
  resizing = FALSE;
}
Beispiel #7
0
void Sample_9_4::initGL()
{
	glPushAttrib(GL_ALL_ATTRIB_BITS);
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glShadeModel (GL_FLAT);
	glEnable(GL_DEPTH_TEST);

	glPushClientAttrib(GL_ALL_CLIENT_ATTRIB_BITS);
	glPixelStorei (GL_UNPACK_ALIGNMENT, 1);

	makeImage();

	glBindTexture(GL_TEXTURE_3D,m_texName);

	glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	glTexImage3D(GL_TEXTURE_3D,0,GL_RGB,iwidth,iheight,idepth, 0,
			GL_RGB,GL_UNSIGNED_BYTE,m_image);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glEnable(GL_TEXTURE_3D);
}
Beispiel #8
0
void CtrlList::onUpdate( Subject<VarPercent> &rPercent, void *arg  )
{
    (void)rPercent; (void)arg;
    // Get the size of the control
    const Position *pPos = getPosition();
    if( !pPos )
        return;

    int height = pPos->getHeight();

    // How many lines can be displayed ?
    int itemHeight = m_rFont.getSize() + LINE_INTERVAL;
    int maxItems = height / itemHeight;

    // Determine what is the first item to display
    VarPercent &rVarPos = m_rList.getPositionVar();
    int firstItem = 0;
    int excessItems = m_rList.size() - maxItems;
    if( excessItems > 0 )
    {
        // a simple (int)(...) causes rounding errors !
#ifdef _MSC_VER
#   define lrint (int)
#endif
        firstItem = lrint( (1.0 - rVarPos.get()) * (double)excessItems );
    }
    if( m_lastPos != firstItem )
    {
        // Redraw the control if the position has changed
        m_lastPos = firstItem;
        makeImage();
        notifyLayout();
    }
}
Beispiel #9
0
void KstBindImage::setMap(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned i = 0;

  if (value.type() != KJS::NumberType || !value.toUInt32(i)) {
    return createPropertyTypeError(exec);
  }

  if (i > 2) {
    return createPropertyRangeError(exec);
  }

  KstImagePtr d = makeImage(_d);
  if (d) {
    KstWriteLocker wl(d);
    switch (i) {
      case 0:
        d->setHasContourMap(false);
        d->setHasColorMap(true);
        break;
      case 1:
        d->setHasContourMap(true);
        d->setHasColorMap(false);
        break;
      case 2:
        d->setHasContourMap(true);
        d->setHasColorMap(true);
        break;
    }
  }
}
Beispiel #10
0
void CtrlTree::onResize()
{
    // Determine what is the first item to display
    VarTree::Iterator it = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();

    int excessItems;
    if( m_flat )
        excessItems = m_rTree.countLeafs() - maxItems();
    else
        excessItems = m_rTree.visibleItems() - maxItems();

    if( excessItems > 0)
    {
        VarPercent &rVarPos = m_rTree.getPositionVar();
        // a simple (int)(...) causes rounding errors !
#ifdef _MSC_VER
#   define lrint (int)
#endif
        if( m_flat )
            it = m_rTree.getLeaf(lrint( (1.0 - rVarPos.get()) * (double)excessItems ) + 1 );
        else
            it = m_rTree.getVisibleItem(lrint( (1.0 - rVarPos.get()) * (double)excessItems ) + 1 );
    }
    // Redraw the control if the position has changed
    m_firstPos = it;
    makeImage();
}
Beispiel #11
0
void my_init()
{
    rot_angle = 0.0;

    glClearColor (0.0, 0.0, 0.0, 0.0);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
	//  生成纹理数据
    makeImage();
	//  设置像素存储模式
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	//  定义二维纹理映射
    glTexImage2D(GL_TEXTURE_2D, 0, 3, ImageWidth, 
		ImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, &Image[0][0][0]);
	//  定义纹理映射参数
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	//  数值纹理环境参数
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
	//  使用二维纹理
    glEnable(GL_TEXTURE_2D);
    glShadeModel(GL_FLAT);
}
Beispiel #12
0
CtrlTree::CtrlTree( intf_thread_t *pIntf,
                    VarTree &rTree,
                    const GenericFont &rFont,
                    const GenericBitmap *pBgBitmap,
                    const GenericBitmap *pItemBitmap,
                    const GenericBitmap *pOpenBitmap,
                    const GenericBitmap *pClosedBitmap,
                    uint32_t fgColor,
                    uint32_t playColor,
                    uint32_t bgColor1,
                    uint32_t bgColor2,
                    uint32_t selColor,
                    const UString &rHelp,
                    VarBool *pVisible,
                    VarBool *pFlat ):
    CtrlGeneric( pIntf,rHelp, pVisible), m_rTree( rTree), m_rFont( rFont ),
    m_pBgBitmap( pBgBitmap ), m_pItemBitmap( pItemBitmap ),
    m_pOpenBitmap( pOpenBitmap ), m_pClosedBitmap( pClosedBitmap ),
    m_fgColor( fgColor ), m_playColor( playColor ), m_bgColor1( bgColor1 ),
    m_bgColor2( bgColor2 ), m_selColor( selColor ),
    m_pLastSelected( NULL ), m_pImage( NULL ), m_dontMove( false ),
    m_pScaledBitmap( NULL )
{
    // Observe the tree and position variables
    m_rTree.addObserver( this );
    m_rTree.getPositionVar().addObserver( this );

    m_flat = pFlat->get();

    m_firstPos = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();

    makeImage();
}
Beispiel #13
0
void CtrlList::onResize()
{
    // Get the size of the control
    const Position *pPos = getPosition();
    if( !pPos )
        return;

    int height = pPos->getHeight();

    // How many lines can be displayed ?
    int itemHeight = m_rFont.getSize() + LINE_INTERVAL;
    int maxItems = height / itemHeight;

    // Update the position variable
    VarPercent &rVarPos = m_rList.getPositionVar();
    int excessItems = m_rList.size() - maxItems;
    if( excessItems > 0 )
    {
        double newVal = 1.0 - (double)m_lastPos / excessItems;
        if( newVal >= 0 )
        {
            // Change the position to keep the same first displayed item
            rVarPos.set( 1.0 - (double)m_lastPos / excessItems );
        }
        else
        {
            // We cannot keep the current first item
            m_lastPos = excessItems;
        }
    }

    makeImage();
}
void CtrlTree::onPositionChange()
{
    m_capacity = maxItems();
    setScrollStep();
    m_firstPos = getFirstFromSlider();
    makeImage();
}
Beispiel #15
0
 DirectionType::DirectionType()
 :myChoice( Choice::rehearsal )
 ,myRehearsalSet()
 ,mySegnoSet()
 ,myWordsSet()
 ,myCodaSet()
 ,myWedge( makeWedge() )
 ,myDynamicsSet()
 ,myDashes( makeDashes() )
 ,myBracket( makeBracket() )
 ,myPedal( makePedal() )
 ,myMetronome( makeMetronome() )
 ,myOctaveShift( makeOctaveShift() )
 ,myHarpPedals( makeHarpPedals() )
 ,myDamp( makeDamp() )
 ,myDampAll( makeDampAll() )
 ,myEyeglasses( makeEyeglasses() )
 ,myStringMute( makeStringMute() )
 ,myScordatura( makeScordatura() )
 ,myImage( makeImage() )
 ,myPrincipalVoice( makePrincipalVoice() )
 ,myAccordionRegistration( makeAccordionRegistration() )
 ,myPercussionSet()
 ,myOtherDirection( makeOtherDirection() )
 {
     myRehearsalSet.push_back( makeRehearsal() );
     mySegnoSet.push_back( makeSegno() );
     myWordsSet.push_back( makeWords() );
     myCodaSet.push_back( makeCoda() );
     myDynamicsSet.push_back( makeDynamics() );
     myPercussionSet.push_back( makePercussion() );
 }
Beispiel #16
0
static NODE_IMPLEMENTATION(resize, Pointer)
{
    MuLangContext* context = static_cast<MuLangContext*>(NODE_THREAD.context());
    const Class*   c       = static_cast<const ImageType*>(NODE_THIS.type());
    ClassInstance* inObj   = NODE_ARG_OBJECT(0, ClassInstance);
    int            width   = NODE_ARG(1, int);
    int            height  = NODE_ARG(2, int);
    ClassInstance* outObj  = makeImage(context, c, width, height);
    ImageStruct*   inIm    = inObj->data<ImageStruct>();
    ImageStruct*   outIm   = outObj->data<ImageStruct>();

    CvMat inMat;
    CvMat outMat;

    cvInitMatHeader(&inMat,
                    inIm->height,
                    inIm->width,
                    CV_32FC(4),
                    inIm->data->data<float>(),
                    0);

    cvInitMatHeader(&outMat,
                    outIm->height,
                    outIm->width,
                    CV_32FC(4),
                    outIm->data->data<float>(),
                    0);

    cvResize(&inMat, &outMat, CV_INTER_AREA);

    NODE_RETURN(outObj);
}
Beispiel #17
0
	/* ------------------------------------------------------------------------------------------ */
	void run () {

		// Create the interface to the Kinect
		char buf [256];
		sprintf(buf, "#%d", id);
		pcl::Grabber* interface = new pcl::OpenNIGrabber(buf);
		boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f =
			boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);

		// Start the interface
		interface->registerCallback (f);
		interface->start ();

		// Set the callback function to get the points
		cv::Vec3s coords (0, 0, -1);
		cv::namedWindow("image", CV_WINDOW_AUTOSIZE);
    cv::setMouseCallback("image", interact, (void*) (&coords));
		bool update = true;

		// Wait
		int counter = 0;
		int lastMouseInput = -1;
		Eigen::Vector3d sumCenter (0,0,0);
		while (true) { //(!viewer.wasStopped()) {

			// Create the image from cloud data
			pthread_mutex_lock(&lock);
			if(update) makeImage();
			pthread_mutex_unlock(&lock);

			// Get the user input if it exists and grow a region around it
			pthread_mutex_lock(&lock2);
			if((coords[2] > 0)) {
				growRegion(coords[0], coords[1]);
				if(coords[2] > lastMouseInput) {
					counter = 0;
					sumCenter = Eigen::Vector3d(0,0,0);
					cout << "----------- reset" << endl;
					lastMouseInput = coords[2];
				}
				// coords[2] = -1;
				if((!(center(0) != center(0))) && center.norm() > 1e-2) {
					counter++;
					sumCenter += center;
				}
				if(counter >= 100) {
					counter = 0;
					cout << "mean center: " << (sumCenter/100).transpose() << endl;
					sumCenter = Eigen::Vector3d(0,0,0);
				}
				// update = false;
			}
			pthread_mutex_unlock(&lock2);
			usleep(1e4);
		}

		// Stop the interface
		interface->stop ();
	}
Beispiel #18
0
void ThresholdedImageDisplayModule::run_()
{
    imageIn.latch();
    // Note that you have to pass a label a QPixmap, but you can't really edit
    // the pixels of a pixmap, so you have to edit a QImage then make a
    // pixmap from it. *rolls eyes*
    setPixmap(QPixmap::fromImage(makeImage(filter)));
}
Beispiel #19
0
ImagePtr MagickImageLoader::load(Magick::Image& image) {
    Magick::Blob blob;
    convertColorSpace(image);
    convertImageToDib(image, blob);
    ImagePtr res = makeImage(blob);
    res->setSize(Size(image.size().width(), image.size().height()));
    return res;
}
Beispiel #20
0
void GLFWView::addRandomCustomPointAnnotations(int count) {
    for (int i = 0; i < count; i++) {
        static int spriteID = 1;
        const auto name = std::string{ "marker-" } + mbgl::util::toString(spriteID++);
        map->addAnnotationImage(makeImage(name, 22, 22, 1));
        spriteIDs.push_back(name);
        annotationIDs.push_back(map->addAnnotation(mbgl::SymbolAnnotation { makeRandomPoint(), name }));
    }
}
Beispiel #21
0
static void
makeImages(void)
{
   int i, sz;

   for (i = 0, sz = SIZE; sz >= 1; i++, sz /= 2) {
      makeImage(i, sz, sz);
      printf("Level %d size: %d x %d\n", i, sz, sz);
   }
}
Beispiel #22
0
void KstBindImage::setMatrix(KJS::ExecState *exec, const KJS::Value& value) {
  KstMatrixPtr mp = extractMatrix(exec, value);
  if (mp) {
    KstImagePtr d = makeImage(_d);
    if (d) {
      KstWriteLocker wl(d);
      d->setMatrix(mp);
    }
  }
}
Beispiel #23
0
KJS::Value KstBindImage::matrix(KJS::ExecState *exec) const {
  KstImagePtr d = makeImage(_d);
  if (d) {
    KstReadLocker rl(d);
    KstMatrixPtr mp = d->matrix();
    if (mp) {
      return KJS::Object(new KstBindMatrix(exec, mp));
    }
  }
  return KJS::Null();
}
Beispiel #24
0
/*
 * Implement the hdu set subcommand:
 *
 *      <path> hdu set $number
 * or:  <path> hdu $number
 *
 * see comments for hduCmd() for details.
 */
int RtdImage::hduCmdSet(int argc, char** argv, FitsIO* fits)
{
    if (strcmp(argv[0], "set") == 0) {
	argc--;
	argv++;
    }
    if (argc != 1)
	return error("wrong number of args: expected HDU number");

    int num = 0;
    if (Tcl_GetInt(interp_, argv[0], &num) != TCL_OK)
	return TCL_ERROR;

    // get a copy so we can change the HDU without changing the original
    fits = fits->copy();
    if (fits->setHDU(num) != 0) {
	delete fits;
	return TCL_ERROR;
    }

    const char* hduType = fits->getHDUType();
    if (!hduType)
	return TCL_ERROR;

    if (*hduType != 'i') {
        delete fits;            // Otherwise just dropped. Note original
                                // FitsIO now positioned ay new HDU anyway.
	return TCL_OK;          // FITS table, not image: don't display
    }

    // save image transformation parameters to restore later
    ImageDataParams p;
    image_->saveParams(p);

    // delete old image
    delete image_;
    image_ = NULL;
    updateViews();

    // Re-initialize the image from the given HDU
    ImageData* im = makeImage(fits);
    if (! im)
	return TCL_ERROR;
    image_ = im;

    // The WCS info will be different in this HDU
    fits->wcsinit();

    // restore transformations
    image_->restoreParams(p, !autoSetCutLevels_);

    // update the display
    return initNewImage();
}
Beispiel #25
0
void Tooltip::displayText( const UString &rText )
{
    // Rebuild the image
    makeImage( rText );

    // Redraw the window if it is already visible
    if( m_xPos != -1 )
    {
        m_pOsTooltip->show( m_xPos, m_yPos, *m_pImage );
    }
}
Beispiel #26
0
void WhiteBall::textureInit() {
	makeImage();
	glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_2D, texture);
	glTexImage2D(GL_TEXTURE_2D, 0, 3, ImageWidth, ImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, &MatrixImage[0][0][0]);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glShadeModel(GL_FLAT);
}
Beispiel #27
0
/** @brief Creates an image and uses it to test the whole module.
 *
 *  This driver receives various parameters for the creation of a specific
 *  bitmap image which will be the test dummy for this module.
 *
 *  @return EXPECTED when everything goes as expected, else UNEXPECTED.
 */
PRIVATE int isWorking() {

	char *fn_iw = "test_isWorking.bmp";
	byte t1, t2;
	dword wid, hei, com;
	word bc;

	BITMAPFILEHEADER f_head;
	BITMAPINFOHEADER i_head;

	printf("<isWorking>\n\n");

	printf("Creating New Image\n");
	printf("Input bfType1: ");
	scanf("%c", &t1);
	printf("Input bfType2: ");
	scanf(" %c", &t2);
	printf("Input biBitCount: ");
	scanf("%hd", &bc);
	printf("Input biCompression: ");
	scanf("%d", &com);
	printf("Input biWidth: ");
	scanf("%d", &wid);
	printf("Input biHeight: ");
	scanf("%d",&hei);
	printf("\n");

	makeFileH(t1, t2, &f_head);
	makeInfoH(wid, hei, bc, com, &i_head);

	makeImage(fn_iw, f_head, i_head);

	if(!list(fn_iw)) {
		printf("</isWorking>\n\n");
		if(remove(fn_iw)) {
			printf("**Error, isWorking() driver unable to remove %s**",fn_iw);
			return UNEXPECTED;
		}
		return EXPECTED;
	}

	if(remove(fn_iw)) {
		printf("**Error, isWorking() driver unable to remove %s**",fn_iw);
		return UNEXPECTED;
	}

	printf("</isWorking>\n\n");
	
	return UNEXPECTED;

}
Beispiel #28
0
void exposeCB (Widget w, 
	ClientData *cd,
	XtcwpAxesCallbackStruct *ca)
/*****************************************************************************
Expose event callback - draws image inside axes box.
If abytes is NULL, simple returns.
If bbytes is NULL, makes bbytes from abytes.
If image is NULL, makes image from bbytes before drawing.
*****************************************************************************/
{
	int nxa=cd->nxa,nya=cd->nya,nxb=cd->nxb,nyb=cd->nyb,
		ixb=cd->ixb,iyb=cd->iyb;
	unsigned char *abytes=cd->abytes,*bbytes=cd->bbytes;
	XImage *image=cd->image;
	Position x=ca->x,y=ca->y;
	Dimension width=ca->width,height=ca->height;
	Display *dpy=XtDisplay(w);
	Window win=XtWindow(w);
	GC gc;

	/* if abytes do not exist, return */
	if (abytes==NULL) return;
	
	/* if necessary, make bbytes */
	if (bbytes==NULL) bbytes = makeBBytes(nxa,nya,abytes,nxb,nyb,ixb,iyb);
		
	/* if necessary, make image */
	if (image==NULL) image = makeImage(dpy,width,height,nxb,nyb,
					   cd->interp,bbytes);

	/* create GC */
	gc = XCreateGC(dpy,win,0L,NULL);
	
	/* draw image */
	XPutImage(dpy,win,gc,image,0,0,x,y,image->width,image->height);
	
	/* free GC */
	XFreeGC(dpy,gc);
	
	/* update client data */
	cd->bbytes = bbytes;
	cd->image = image;
	cd->exposed = 1;

	/* update axes */
	if (strchr(cd->format,'%') && !strstr(cd->format,"%%")) {
		sprintf(cd->title,cd->format,cd->fframe+cd->iframe*cd->dframe);
		XtVaSetValues(cd->axes,XtNtitle,cd->title,NULL);
	}
}
void mouse(int btn, int state, int x, int y){
	y=m-y;
	if( btn==GLUT_LEFT_BUTTON){
		if(state==GLUT_DOWN){
			//zoom in
			xtemp1=x;
			xtemp2=x;
			ytemp1=y;
			boxCount=0;
		}else if(state == GLUT_UP && xtemp1!=xtemp2){
			double xptSize = dimention[dimIter].width/n;
			double yptSize = dimention[dimIter].height/m;
			double x1pos = (xtemp1 - 250.0)*xptSize+dimention[dimIter].cx;
			double y1pos = (ytemp1 - 250.0)*yptSize+dimention[dimIter].cy;
			double x2pos = (xtemp2 - 250.0)*xptSize+dimention[dimIter].cx;
			double y2pos = (ytemp2 - 250.0)*yptSize+dimention[dimIter].cy;

			dimention[dimIter+1].cx = (((xtemp2+xtemp1)/2)-250)*xptSize+dimention[dimIter].cx;
			dimention[dimIter+1].cy = (((ytemp2+ytemp1)/2)-250)*yptSize+dimention[dimIter].cy;

			dimention[dimIter+1].height= y2pos-y1pos;
			if(dimention[dimIter+1].height<0){
				dimention[dimIter+1].height = dimention[dimIter+1].height*-1.0;
			}
			dimention[dimIter+1].width = x2pos-x1pos;
			if(dimention[dimIter+1].width<0){
				dimention[dimIter+1].width= dimention[dimIter+1].width*-1.0;
			}
			dimIter++;
			makeImage();
			glDrawPixels(n,m,GL_COLOR_INDEX, GL_UNSIGNED_BYTE, dimention[dimIter].image);
			glFlush();
		}
	}
	if(btn==GLUT_RIGHT_BUTTON && state == GLUT_DOWN){
		//zoom out
		if(dimIter-1>=0){
			//dimention[dimIter].height = dimention[dimIter-1].height;
			//dimention[dimIter].width = dimention[dimIter-1].width;
			//dimention[dimIter].cx = dimention[dimIter-1].cx;
			//dimention[dimIter].cy = dimention[dimIter-1].cy;
			dimIter--;
			//makeImage();
			glDrawPixels(n,m,GL_COLOR_INDEX, GL_UNSIGNED_BYTE, dimention[dimIter].image);
			glFlush();
		}
	}
}
Beispiel #30
0
CtrlList::CtrlList( intf_thread_t *pIntf, VarList &rList,
                    const GenericFont &rFont, const GenericBitmap *pBitmap,
                    uint32_t fgColor, uint32_t playColor, uint32_t bgColor1,
                    uint32_t bgColor2, uint32_t selColor,
                    const UString &rHelp, VarBool *pVisible ):
    CtrlGeneric( pIntf, rHelp, pVisible ), m_rList( rList ), m_rFont( rFont ),
    m_pBitmap( pBitmap ), m_fgColor( fgColor ), m_playColor( playColor ),
    m_bgColor1( bgColor1 ), m_bgColor2( bgColor2 ), m_selColor( selColor ),
    m_pLastSelected( NULL ), m_pImage( NULL ), m_lastPos( 0 )
{
    // Observe the list and position variables
    m_rList.addObserver( this );
    m_rList.getPositionVar().addObserver( this );

    makeImage();
}