Ejemplo n.º 1
0
//骨架化
void CImageProcess::Thinning(Image &source, Image &dst){
	memset(dst._pData, 0, dst._height * dst._width);
	IplImage *tmp = CreateImage(source);
	IplImage *tmp_d = CreateImage(dst);
	cv::Mat src(tmp, 0);
	cv::Mat	dst_t(tmp_d);
	dst_t = src.clone();
	dst_t /= 255;         // convert to binary image

	cv::Mat prev = cv::Mat::zeros(dst_t.size(), CV_8UC1);
	cv::Mat diff;

	do {
		ThinningIteration(dst_t, 0);
		ThinningIteration(dst_t, 1);
		cv::absdiff(dst_t, prev, diff);
		dst_t.copyTo(prev);
	} 
	while (cv::countNonZero(diff) > 0);

	dst_t *= 255;
	IplImage tmp_(dst_t);
	IplImge2Image(&tmp_, dst);
	ReleaseUserImage(&tmp);
	ReleaseUserImage(&tmp_d);
}
Ejemplo n.º 2
0
void InitInterface_RR(string iniName,ref myCh,ref enemyCh)
{
	refMyCharacter = myCh;
	refEnemyCharacter = enemyCh;
    GameInterface.title = "titleRansack";

    SendMessage(&GameInterface,"ls",MSG_INTERFACE_INIT,iniName);
    SetVariable();

	ref shipRef = GetShipByType(sti(refMyCharacter.ship.Type));
	CreateImage("myShip","SHIPS",shipRef.name,32,39,160,167);
    CreateImage("myFace","FACE128_"+refMyCharacter.FaceId,"face",164,39,292,167);
    CreateString(TRUE,"MyShipType",XI_ConvertString(shipRef.Name),FONT_NORMAL,COLOR_NORMAL,96,140,SCRIPT_ALIGN_CENTER,1.0);
    CreateString(TRUE,"MyShipName",refMyCharacter.ship.Name,FONT_NORMAL,COLOR_NORMAL,177,198,SCRIPT_ALIGN_CENTER,1.0);

	shipRef = GetShipByType(sti(refEnemyCharacter.ship.Type));
	CreateImage("enemyShip","SHIPS",shipRef.name,480,39,608,167);
    CreateImage("enemyFace","FACE128_"+refEnemyCharacter.FaceId,"face",348,39,476,167);
    CreateString(TRUE,"EnemyShipType",XI_ConvertString(shipRef.Name),FONT_NORMAL,COLOR_NORMAL,544,140,SCRIPT_ALIGN_CENTER,1.0);
    CreateString(TRUE,"EnemyShipName",refEnemyCharacter.ship.Name,FONT_NORMAL,COLOR_NORMAL,463,198,SCRIPT_ALIGN_CENTER,1.0);

	CreateString(TRUE,"String1",XI_ConvertString(str1),FONT_NORMAL,COLOR_NORMAL,320,240,SCRIPT_ALIGN_CENTER,1.0);
	CreateString(TRUE,"String2",XI_ConvertString(str2),FONT_NORMAL,COLOR_NORMAL,320,268,SCRIPT_ALIGN_CENTER,1.0);
	CreateString(TRUE,"String3",XI_ConvertString(str3_1)+" "+nSurrenderedMen+" "+XI_ConvertString(str3_2),FONT_NORMAL,COLOR_NORMAL,320,296,SCRIPT_ALIGN_CENTER,1.0);

	SetEventHandler("InterfaceBreak","ProcessCancelExit",0);
    SetEventHandler("InterfaceCancel","ProcessCancelExit",0);
	SetEventHandler("KillPress","KillProcess",0);
	SetEventHandler("SlavesPress","SlavesProcess",0);
}
void RegionsToSIFTDescriptors( PStack regions, PStack descriptors, int pb, int ob, int psize ) {
	
	if ( regions == NULL || descriptors == NULL ) return;
	
	if ( psize % 2 == 0 ) psize++;
	Image patch = CreateImage(psize*sqrt(2),psize*sqrt(2));
	Image rpatch = CreateImage(psize,psize);
	FStack orientations = NewFStack(15);
	
	int k;
	
	for (k=0;k<regions->stacksize;k++) {
		Region region = regions->items[k];
		RegionToPatch(region,region->image,patch,6.0);
		DeterminePatchOrientations(patch,orientations);
		while ( !FStackEmpty(orientations) ) {
			float orientation = PopFStack(orientations);
			RotateImage(patch,rpatch,orientation);
			float * newDescriptor = PCADescriptorFromPatch(rpatch);
			PushPStack(descriptors,NewDescriptor(region,36,3,newDescriptor));
		}
	}
	
	FreeFStack(orientations);
	FreeImage(patch); FreeImage(rpatch);

}
Ejemplo n.º 4
0
/* Find the local maxima and minima of the DOG images in scale space.
   Return the keypoints for these locations, added to existing "keys".
*/
KKeypoint FindMaxMin(Image *dogs, Image *blur, float octSize, KKeypoint keys)
{
   int s, r, c, rows, cols;
   float val, **pix;
   Image map, grad, ori;
   
   rows = dogs[0]->rows;
   cols = dogs[0]->cols;

   /* Create an image map in which locations that have a keypoint are
      marked with value 1.0, to prevent two keypoints being located at
      same position.  This may seem an inefficient data structure, but
      does not add significant overhead.
   */
   map = CreateImage(rows, cols, IMAGE_POOL);
   for (r = 0; r < rows; r++)
     for (c = 0; c < cols; c++)
       map->pixels[r][c] = 0.0;

   /* Search through each scale, leaving 1 scale below and 1 above.
      There are Scales+2 dog images.
   */
   for (s = 1; s < Scales+1; s++) {
      
     /* For each intermediate image, compute gradient and orientation
	images to be used for keypoint description.
     */
     grad = CreateImage(rows, cols, IMAGE_POOL);
     ori = CreateImage(rows, cols, IMAGE_POOL);
     GradOriImages(blur[s], grad, ori);

     pix = dogs[s]->pixels;   /* Pointer to pixels for this scale. */

     /* Only find peaks at least BorderDist samples from image border, as
	peaks centered close to the border will lack stability.
     */
     assert(BorderDist >= 2);
     for (r = BorderDist; r < rows - BorderDist; r++)
       for (c = BorderDist; c < cols - BorderDist; c++) {
	 val = pix[r][c];       /* Pixel value at (r,c) position. */

	 /* DOG magnitude must be above 0.8 * PeakThresh threshold
	    (precise threshold check will be done once peak
	    interpolation is performed).  Then check whether this
	    point is a peak in 3x3 region at each level, and is not
	    on an elongated edge.
	 */
	 if (fabs(val) > 0.8 * PeakThresh  &&
	     LocalMaxMin(val, dogs[s], r, c) &&
	     LocalMaxMin(val, dogs[s-1], r, c) &&
	     LocalMaxMin(val, dogs[s+1], r, c) &&
	     NotOnEdge(dogs[s], r, c))
	   keys = InterpKeyPoint(dogs, s, r, c, grad, ori, map, octSize,
				 keys, 5);
       }
   }
   return keys;
}
Ejemplo n.º 5
0
Image *WaterGray(Image *img, Image *marker, AdjRel *A)
{
  Image *cost=NULL,*label=NULL, *pred=NULL;
  GQueue *Q=NULL;
  int i,p,q,tmp,n,lambda=1;
  Pixel u,v;

  n     = img->ncols*img->nrows;
  cost  = CreateImage(img->ncols,img->nrows);
  label = CreateImage(img->ncols,img->nrows);
  pred  = CreateImage(img->ncols,img->nrows);
  Q     = CreateGQueue(MaximumValue(marker)+2,n,cost->val);

  // Trivial path initialization

  for (p=0; p < n; p++) {
    cost->val[p]=marker->val[p]+1;
    pred->val[p]=NIL;
    InsertGQueue(&Q,p);
  }

  // Path propagation

  while(!EmptyGQueue(Q)) {
    p=RemoveGQueue(Q);
    if (pred->val[p]==NIL) { // on-the-fly root detection
      cost->val[p] =img->val[p];
      label->val[p]=lambda; lambda++;
    }
    u.x = p%img->ncols;
    u.y = p/img->ncols;
    for (i=1; i < A->n; i++){
      v.x = u.x + A->dx[i];
      v.y = u.y + A->dy[i];
      if (ValidPixel(img,v.x,v.y)){
	q = v.x + img->tbrow[v.y];
	if (cost->val[q] > cost->val[p]){
	  tmp = MAX(cost->val[p],img->val[q]);
	  if (tmp < cost->val[q]){
	    RemoveGQueueElem(Q,q);
	    pred->val[q]  = p;
	    label->val[q] = label->val[p];
	    cost->val[q]  = tmp;
	    InsertGQueue(&Q,q);
	  }
	}
      }
    }
  }
  DestroyGQueue(&Q);
  DestroyImage(&cost);
  DestroyImage(&pred);

  return(label);
}
Ejemplo n.º 6
0
void
PNGTests::testWriter() {
  static const int width  = 256;
  static const int height = 256;

  // create an image and fill it with random data
  auto_ptr<Image> image(CreateImage(width, height, PF_R8G8B8A8));
  setRandomBytes((byte*)image->getPixels(), width * height * 4);

  // generate filename
  char* filename = tmpnam(0);
  CPPUNIT_ASSERT_MESSAGE("opening temporary file", filename != 0);

  // save image
  CPPUNIT_ASSERT(SaveImage(filename, FF_PNG, image.get()) == true);

  // load it back
  auto_ptr<Image> img2(OpenImage(filename, PF_R8G8B8A8));
  CPPUNIT_ASSERT_MESSAGE("reloading image file", img2.get() != 0);

  AssertImagesEqual(
    "comparing saved with loaded",
    image.get(),
    img2.get());

  // force pixel format conversion (don't destroy the old image)
  auto_ptr<Image> img3(OpenImage(filename, PF_R8G8B8));
  CPPUNIT_ASSERT(SaveImage(filename, FF_PNG, img3.get()) == true);

  remove(filename);


  //== PALETTIZED SAVING TEST ==
  // disabled until loading palettized PNGs with a correct palette format
  // is implemented.
#if 0
  char* plt_filename = tmpnam(0);
  CPPUNIT_ASSERT_MESSAGE("opening temporary file (palette)", plt_filename != 0);
  auto_ptr<Image> plt(CreateImage(256, 256, PF_I8, 256, PF_R8G8B8));
  setRandomBytes((byte*)plt->getPixels(), 256 * 256);
  setRandomBytes((byte*)plt->getPalette(), 256);

  CPPUNIT_ASSERT(SaveImage(plt_filename, FF_PNG, plt.get()) == true);

  auto_ptr<Image> plt2(OpenImage(plt_filename, FF_PNG));
  CPPUNIT_ASSERT_MESSAGE("reloading palettized image", plt2.get() != 0);
  CPPUNIT_ASSERT(plt2->getPaletteSize() == 256);
  CPPUNIT_ASSERT(plt2->getPaletteFormat() == PF_R8G8B8);
  CPPUNIT_ASSERT(plt2->getFormat() == PF_I8);
  AssertImagesEqual("Comparing palettized image", plt.get(), plt2.get());

  remove(plt_filename);
#endif
}
Ejemplo n.º 7
0
int main() {
	Handle splash = 0;
	CreateImage(splash, splash_png, sizeof(splash_png));
	DrawImage(splash, 0, 0);
	UpdateScreen();
	do {
		Wait(WAIT_KEY);
		if(GetKeys() & MAK_FIRE)
			break;
	} while(1);
	DestroyObject(splash);

	Handle backg = 0;
	CreateImage(backg, ttsdemo_png, sizeof(ttsdemo_png));
	DrawImage(backg, 0, 0);
	UpdateScreen();

	int oldKeys = GetKeys();
	while(1) {
		Wait(WAIT_KEY);
		int newKeys = GetKeys();
		int downedKeys = newKeys & (~oldKeys);
		oldKeys = newKeys;

		if(downedKeys)
			StopSpeaking();

		if(downedKeys & MAK_FIRE) {
			StartSpeaking("Du står i korsningen Götgatan Åsögatan riktning Slussen. En meter till "
				"vänster om dig är ett övergångställe, för passage över Götgatan med "
				"tryckknapp för gångtrafikanter. Vid trottoarkanten löper en cykelväg.");
		}
		if(downedKeys & MAK_DOWN) {
			StartSpeaking("Tre meter bakom dig i riktning Skanstull är ett övergångställe för "
				"passage över Åsögatan.");
		}
		if(downedKeys & MAK_UP) {
			StartSpeaking("Trottoaren rakt framfortsätter 50 meter till nästa korsning Folkungagatan. "
				"På andra sidan av övergångstället finns ingångar till tunnelbanestation "
				"medborgarplatsen.");
		}
		/*if(downedKeys & MAK_RIGHT) {
		StartSpeaking("Am I right? Of course I'm right.");
		}
		if(downedKeys & MAK_LEFT) {
		StartSpeaking("No one is left behind.");
		}*/
	}
	return 0;
}
Ejemplo n.º 8
0
const Entity EntityBuilder::CreateSlider(const XMFLOAT3& pos, float width, float height, float minv, float maxv, float defval, float size1, bool real, const std::string& text, float fontSize, float size2, std::function<void()> change, const  XMFLOAT4& textColor)
{
	Slider* s = nullptr;
	try { s = new Slider(minv,maxv,width, height,defval, real, std::move(change)); }
	catch (std::exception& e) { e;SAFE_DELETE(s); throw ErrorMsg(1500003, L"Could not create slider"); }

	Entity ent = _entity.Create();
	_transform->CreateTransform(ent);
	Entity rail = CreateImage(XMFLOAT3(size2, height / 2.0f - height / 16.0f, 0.0f), width+ height / 4.0f, height / 8.0f, "Assets/Textures/Light_Bar.png");
	Entity slidebar = CreateImage(XMFLOAT3(size2+width*((defval-minv)/(maxv-minv)), height/2.0f- height/4.0f, 0.0f), height / 2.0f, height / 2.0f, "Assets/Textures/Slide_Bar.png");
	Entity la = CreateLabel(XMFLOAT3(0.0f,0.0f,0.0f), text, fontSize, textColor, size2, height, "");
	Entity vtext = CreateLabel(XMFLOAT3(width + size2 + height / 2.0f, 0.0f, 0.0f), (real) ? to_string((double)defval) : to_string((int)defval), fontSize, textColor, size1, height, "");
	
	_transform->BindChild(ent, slidebar);
	_transform->BindChild(ent, la);
	_transform->BindChild(ent, vtext);
	_transform->BindChild(ent, rail);

	_transform->SetPosition(ent, pos);

	_controller->AddSlider(ent, s);

	auto i = System::GetInput();
	_event->BindEvent(slidebar, EventManager::EventType::Drag,
		[s,this, slidebar,i,size2,vtext]() 
	{
		int x, y;
		i->GetMouseDiff(x, y);
		float currp = s->width*((s->curr - s->minv) / (s->maxv - s->minv));
		currp += x;
		s->curr = (currp / s->width)*(s->maxv - s->minv) + s->minv;
		if (s->curr >= s->maxv)
			s->curr = s->maxv;
		else if (s->curr <= s->minv)
			s->curr = s->minv;
		else
		{
			this->_transform->SetPosition(slidebar, XMFLOAT3(size2 + currp, s->height / 2.0f - s->height / 4.0f, 0.0f));
			
			
		}
		s->change();
		this->_text->ChangeText(vtext, (s->real) ? to_string((double)s->curr) : to_string((int)s->curr));
	});

	return ent;

}
Ejemplo n.º 9
0
void CImageProcess::ZoomImage(Image &in, Image &out, const char *cName)
{
	IplImage *image = CreateImage(in);
	IplImage *pDst = CreateImage(out);

	cvResize(image, pDst, CV_INTER_AREA );

	if(cName){
		cvNamedWindow(cName, CV_WINDOW_AUTOSIZE);
		cvShowImage(cName,pDst);
	}


	//cvSaveImage("1.png",pDst);
	IplImge2Image(pDst, out);
}
Ejemplo n.º 10
0
int main()
{
	glfwInit();

	window = glfwCreateWindow(IMAGE_WIDTH,IMAGE_HEIGHT,"MTF",NULL,NULL);
	if (!window)
		return 100;

	LoadConstants();
	
	glfwSetCursorPosCallback(window,glfwMouse);
	glfwSetWindowSizeCallback(window,glfwResize);
	glfwSetKeyCallback(window,glfwKeyboard);
	glfwMakeContextCurrent(window);

	glClearColor(1.0,0.0,0.0,1.0);
	glViewport(0,0,IMAGE_WIDTH,IMAGE_HEIGHT);
	CreateImage(IMAGE_WIDTH,IMAGE_HEIGHT);
	CreateMTFImage();
	SetImageData(IMAGE_WIDTH,IMAGE_HEIGHT,image_data);


	while(true)
	{
		glClear(GL_COLOR_BUFFER_BIT);

		DrawImage();

		glfwSwapBuffers(window);
		glfwPollEvents();

		if (glfwWindowShouldClose(window))
			return 0;
	}
}
//----------------------------------------------------------------------------
void AdaptiveSkeletonClimbing3::Test ()
{
    int N = 6, bound = (1 << N) + 1;
    ImageInt3D image(bound, bound, bound);
    CreateImage(image);

    float* data = new1<float>(image.GetQuantity());
    int i;
    for (i = 0; i < image.GetQuantity(); ++i)
    {
        data[i] = (float)image[i];
    }

    Climb3D asc(N, data);
    float level = 349.5f;
    int depth = -1;

    int numVertices, numTriangles;
    Vector3f* vertices = 0;
    TriangleKey* triangles = 0;
    asc.ExtractContour(level, depth, numVertices, vertices, numTriangles,
        triangles);
    asc.MakeUnique(numVertices, vertices, numTriangles, triangles);
    asc.OrientTriangles(vertices, numTriangles, triangles, false);

    Vector3f* normals = asc.ComputeNormals(numVertices, vertices,
        numTriangles, triangles);

    std::ofstream outFile("vtdata.txt");
    outFile << numVertices << std::endl;
    for (i = 0; i < numVertices; ++i)
    {
        Vector3f& vertex = vertices[i];
        outFile << vertex[0] << " " << vertex[1] << " " << vertex[2]
            << std::endl;
    }
    outFile << std::endl;

    for (i = 0; i < numVertices; ++i)
    {
        Vector3f& normal = normals[i];
        outFile << normal[0] << " " << normal[1] << " " << normal[2]
            << std::endl;
    }
    outFile << std::endl;

    outFile << numTriangles << std::endl;
    for (i = 0; i < numTriangles; ++i)
    {
        TriangleKey& triangle = triangles[i];
        outFile << triangle.V[0] << " " << triangle.V[1] << " "
            << triangle.V[2] << std::endl;
    }

    delete1(normals);
    delete1(triangles);
    delete1(vertices);

    asc.PrintBoxes("boxes.txt");
}
Ejemplo n.º 12
0
CImage::CImage(const CImage &oCopy, int iZoom) {
	// Set the relative parameters
	m_eImageType = oCopy.m_eImageType;
	m_iWidth = oCopy.m_iWidth;
	m_iHeight = oCopy.m_iHeight;
	// Allocate the memory
	IRESULT eResult = CreateImage();
	// If image data has been allocated ok, copy over
	if (eResult == I_OK) {
		memcpy(m_pData, oCopy.m_pData, m_iDataSize * 4);
		if ((m_eImageType == IT_PALETTE) && (oCopy.m_poPalette))
			m_poPalette->Copy(oCopy.m_poPalette);
	}
	// Scale the copied image
	if (eResult == I_OK) {
		int iWidth = m_iWidth, iHeight = m_iHeight;
		while (iZoom) {
			if (iZoom > 0) {
				iZoom--;
				iWidth <<= 1;
				iHeight <<= 1;
			}
			else {
				iZoom++;
				iWidth >>= 1;
				iHeight >>= 1;
			}
		}
		eResult = Scale(iWidth, iHeight);
	}
int main(int, char* [] )
{
  typedef itk::Image<unsigned char, 2> ImageType;
  ImageType::Pointer image = ImageType::New();
  CreateImage(image.GetPointer());

  const unsigned int numberOfIterations = 1e5;

  // Create a list of the indices in the image
  itk::ImageRegionConstIteratorWithIndex<ImageType> imageIterator(image, image->GetLargestPossibleRegion());
  std::vector<itk::Index<2> > indices;

  while(!imageIterator.IsAtEnd())
  {
    indices.push_back(imageIterator.GetIndex());
    ++imageIterator;
  }

  unsigned int total = 0; // To make sure the loop isn't optimized away
  for(unsigned int i = 0; i < numberOfIterations; ++i)
  {
//    total += Iterator(image.GetPointer()); // 1.4s
    total += GetPixel(image.GetPointer(), indices); // 5.9s
  }

  std::cout << "total " << total << std::endl; // To make sure the loop isn't optimized away

  return 0;
}
Ejemplo n.º 14
0
	CImageTilePattern*CDocument::CreateHatchPattern(double dW, double dH, const BYTE& nR1, const BYTE& nG1, const BYTE& nB1, const BYTE& nAlpha1, const BYTE& nR2, const BYTE& nG2, const BYTE& nB2, const BYTE& nAlpha2, const std::wstring& wsHatch)
	{
		// TODO: Надо бы сделать мап, чтобы не создавать одинаковых паттернов

		CImageDict* pImage = CreateImage();
		BYTE* pBuffer = new BYTE[3 * HATCH_TX_SIZE * HATCH_TX_SIZE];
		if (!pBuffer)
			return NULL;

		TColor oColor1(nR1, nG1, nB1);
		TColor oColor2(nR2, nG2, nB2);
		agg::GetHatchPattern<TColor>(wsHatch, (TColor*)pBuffer, oColor1, oColor2);
		pImage->LoadRaw(pBuffer, 3 * HATCH_TX_SIZE * HATCH_TX_SIZE, HATCH_TX_SIZE, HATCH_TX_SIZE);
		delete[] pBuffer;

		if (255 != nAlpha1 || 255 != nAlpha2)
		{
			BYTE* pSMask = new BYTE[HATCH_TX_SIZE * HATCH_TX_SIZE];
			if (pSMask)
			{
				agg::GetHatchPattern<BYTE>(wsHatch, pSMask, nAlpha1, nAlpha2);
				pImage->LoadSMask(pSMask, (unsigned int)HATCH_TX_SIZE * HATCH_TX_SIZE, (unsigned int)HATCH_TX_SIZE, (unsigned int)HATCH_TX_SIZE);
				delete[] pSMask;
			}
		}

		return CreateImageTilePattern(dW, dH, pImage, NULL, imagetilepatterntype_Default);
	}
Ejemplo n.º 15
0
/* Double image size. Use linear interpolation between closest pixels.
   Size is two rows and columns short of double to simplify interpolation.
*/
SiftImage DoubleSize(SiftImage image)
{
   int rows, cols, nrows, ncols, r, c, r2, c2;
   double **im, **newc;
   SiftImage newimage;
   
   rows = image->rows;
   cols = image->cols;
   nrows = 2 * rows - 2;
   ncols = 2 * cols - 2;
   newimage = CreateImage(nrows, ncols, IMAGE_POOL);
   im = image->pixels;
   newc = newimage->pixels;
   
   for (r = 0; r < rows - 1; r++)
      for (c = 0; c < cols - 1; c++) {
         r2 = 2 * r;
         c2 = 2 * c;
         newc[r2][c2] = im[r][c];
         newc[r2+1][c2] = 0.5 * (im[r][c] + im[r+1][c]);
         newc[r2][c2+1] = 0.5 * (im[r][c] + im[r][c+1]);
         newc[r2+1][c2+1] = 0.25 * (im[r][c] + im[r+1][c] + im[r][c+1] +
            im[r+1][c+1]);
      }
   return newimage;
}
Ejemplo n.º 16
0
IMAGE* ReadOneFrame(const char *fname, int nFrame, unsigned int W, unsigned H)
{
        /*defining local variables*/
        FILE *file;

        unsigned int x, y;
        unsigned char ch;
        IMAGE* image ;

        /*checking error*/
        assert(fname);
        assert(nFrame >= 0);

        image = CreateImage(W, H) ;
        assert(image) ;

        /*opening file stream*/
        file = fopen(fname, "r");
        assert(file) ;

        /*find desired frame*/
        fseek(file, 1.5 * nFrame * W * H, SEEK_SET);

        for(y = 0; y < H; y ++){
                for(x = 0; x < W; x ++){
                        ch = fgetc(file);
                        SetPixelY(image, x, y, ch);
                }/*rof*/
        }

        for(y = 0; y < H ; y += 2){
                for(x = 0; x < W ; x += 2){
                        ch = fgetc(file);
                        SetPixelU(image, x, y, ch);
                        SetPixelU(image, x + 1, y, ch);
                        SetPixelU(image, x, y + 1, ch);
                        SetPixelU(image, x + 1, y + 1, ch);
                }
        }

        for(y = 0; y < H ; y += 2){
                for(x = 0; x < W ; x += 2){
                        ch = fgetc(file);
                        SetPixelV(image, x, y, ch);
                        SetPixelV(image, x + 1, y, ch);
                        SetPixelV(image, x, y + 1, ch);
                        SetPixelV(image, x + 1, y + 1, ch);
                }
        }

        /*checking for error*/

        assert(ferror(file) == 0) ;

        /*closing stream and terminating*/
        fclose(file);
        file = NULL;
        return image;
}
Ejemplo n.º 17
0
void pMenu::setImage(const image &image) {
  if(image.empty() == false) {
    GtkImage *gtkImage = CreateImage(image, true);
    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), (GtkWidget*)gtkImage);
  } else {
    gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), nullptr);
  }
}
Ejemplo n.º 18
0
VkTextureImage *VkHardwareTexture::GetImage(FTexture *tex, int translation, int flags)
{
	if (!mImage.Image)
	{
		CreateImage(tex, translation, flags);
	}
	return &mImage;
}
Ejemplo n.º 19
0
Image::Image(const char* pszImageFile)
{
	m_nImageWidth = 0;
	m_nImageHeight = 0;
	m_nBPP = 0;
	m_pPixelData = NULL;
	m_bOK = CreateImage(pszImageFile);
}
Ejemplo n.º 20
0
clImage* clResourcesManager::CreateImageFromBitmap( clBitmap* Bitmap ) const
{
	clImage* Res = CreateImage();

	Res->SetBitmap( Bitmap );

	return Res;
}
Ejemplo n.º 21
0
int _tmain(int argc, _TCHAR* argv[])
{
	//IplImage *c = cvLoadImage("000000009.jpg");
	//cvShowImage("c", c);
	//cvWaitKey(0);
	for (int i = 1; i <= 307; i++)
		CreateImage(i, "K:\\beijing\\Video\\VideoSYS\\overallImage\\", "K:\\beijing\\Video\\Video\\tmpimg\\");
	return 0;
}
Ejemplo n.º 22
0
ImageForest *CreateImageForest(Image *img)
{
  int p, n = img->ncols * img->nrows; 
  ImageForest *fst = (ImageForest *)calloc(1,sizeof(ImageForest));
  
  fst->cost  = CreateImage(img->ncols,img->nrows);
  fst->pred  = CreateImage(img->ncols,img->nrows);
  fst->label = CreateImage(img->ncols,img->nrows);
  fst->root  = CreateImage(img->ncols,img->nrows);

  for (p=0; p < n; p++) {
    fst->cost->val[p]  = INT_MAX;
    fst->root->val[p]  = p;
    fst->pred->val[p]  = NIL;
    fst->label->val[p] = 0;
  }
  return(fst);
}
Ejemplo n.º 23
0
void IdePngDes::Create(const char *_filename)
{
	Clear();
	filename = _filename;
	filetime = GetSysTime();
	Image m = CreateImage(Size(16, 16), Null);
	AddImage(filename, m, false);
	SingleMode();
}
Ejemplo n.º 24
0
EXPORT(IMAGE) CloneImage(IMAGE image)
{
    if (!image)
        return NULL;

    IMAGE clone = CreateImage(image->width, image->height, LockImage(image));
    UnlockImage(image, false);

    return clone;
}
Ejemplo n.º 25
0
CImage *CreateCImage(int ncols, int nrows)
{
  CImage *cimg=NULL;
  int i;

  cimg = (CImage *) calloc(1, sizeof(CImage));
  for (i=0; i < 3; i++) 
    cimg->C[i] = CreateImage(ncols,nrows);
  return(cimg);
}
Ejemplo n.º 26
0
Image *AddValue(Image *img, int H)
{
  Image *marker=CreateImage(img->ncols,img->nrows);
  int p,n=img->ncols*img->nrows;

  for (p=0; p < n; p++)
    marker->val[p]=img->val[p]+H;

  return(marker);
}
Ejemplo n.º 27
0
bool GrVkImage::InitImageInfo(const GrVkGpu* gpu, const ImageDesc& imageDesc, GrVkImageInfo* info) {
    VkImage image = 0;
    GrVkAlloc alloc;

    bool isLinear = VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling;
    VkImageLayout initialLayout = isLinear ? VK_IMAGE_LAYOUT_PREINITIALIZED
                                           : VK_IMAGE_LAYOUT_UNDEFINED;

    // Create Image
    VkSampleCountFlagBits vkSamples;
    if (!GrSampleCountToVkSampleCount(imageDesc.fSamples, &vkSamples)) {
        return false;
    }

    SkASSERT(VK_IMAGE_TILING_OPTIMAL == imageDesc.fImageTiling ||
             VK_SAMPLE_COUNT_1_BIT == vkSamples);

    // sRGB format images may need to be aliased to linear for various reasons (legacy mode):
    VkImageCreateFlags createFlags = GrVkFormatIsSRGB(imageDesc.fFormat, nullptr)
        ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0;

    const VkImageCreateInfo imageCreateInfo = {
        VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,         // sType
        NULL,                                        // pNext
        createFlags,                                 // VkImageCreateFlags
        imageDesc.fImageType,                        // VkImageType
        imageDesc.fFormat,                           // VkFormat
        { imageDesc.fWidth, imageDesc.fHeight, 1 },  // VkExtent3D
        imageDesc.fLevels,                           // mipLevels
        1,                                           // arrayLayers
        vkSamples,                                   // samples
        imageDesc.fImageTiling,                      // VkImageTiling
        imageDesc.fUsageFlags,                       // VkImageUsageFlags
        VK_SHARING_MODE_EXCLUSIVE,                   // VkSharingMode
        0,                                           // queueFamilyCount
        0,                                           // pQueueFamilyIndices
        initialLayout                                // initialLayout
    };

    GR_VK_CALL_ERRCHECK(gpu->vkInterface(), CreateImage(gpu->device(), &imageCreateInfo, nullptr,
                                                        &image));

    if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, isLinear, &alloc)) {
        VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr));
        return false;
    }

    info->fImage = image;
    info->fAlloc = alloc;
    info->fImageTiling = imageDesc.fImageTiling;
    info->fImageLayout = initialLayout;
    info->fFormat = imageDesc.fFormat;
    info->fLevelCount = imageDesc.fLevels;
    return true;
}
Ejemplo n.º 28
0
int main(int argc, char **argv) {
	// Start 'er up
	g_oCGI.Init(argc, argv);
	// Write banner, if in debug mode
	if (g_oCGI.CorrectRequest(CGI_M_NONE)) {
		printf("Counter %s (%s)\n", COUNTER_VERSION, __DATE__);
		printf("Copyright 2000 Vapour Technology Ltd.\n\n");
	}
	// Add the valid referrers here
	int iCount = 0;
	while (g_pcReferrers[iCount][0] != '\0') {
		g_oCGI.AddReferrer(g_pcReferrers[iCount++]);
	}
	// Check to see we have a valid referrer
	if (!g_oCGI.ValidReferrer()) {
		Error("Invalid referrer");
		return -1;
	}
	// Build the count data file
	char pcCountName[STR_SIZE] = COUNTER_ROOT;
	const char *pcCountID = g_oCGI.GetValue("id");
	if (pcCountID) {
		strcat(pcCountName, pcCountID);
	}
	else {
		Error("No ID specified");
		return -1;
	}
	// Load the data file and returns the count string
	char pcCount[STR_SIZE] = "";
	GetCount(pcCountName, pcCount);
	if (strlen(pcCount) == 0) {
		Error("Unable to retrieve count data");
		return -1;
	}
	// Check the amount of digits
	int iDigits = COUNTER_DIGITS;
	const char *pcDigits = g_oCGI.GetValue("digits");
	if (pcDigits)
		iDigits = atoi(pcDigits);
	// Get the font name
	char pcFontPath[STR_SIZE] = COUNTER_ROOT;
	const char *pcFontName = g_oCGI.GetValue("font");
	if (pcFontName)
		strcat(pcFontPath, pcFontName);
	else
		strcat(pcFontPath, "normal");
	// Write then, create the image
	if (!CreateImage(pcCount, pcFontPath, iDigits)) {
		Error("Unable to create counter image");
		return -1;
	}

	return 0;
}
Ejemplo n.º 29
0
nsresult
nsSVGFilterInstance::BuildSourcePaint(PrimitiveInfo *aPrimitive)
{
  NS_ASSERTION(aPrimitive->mImageUsers > 0, "Some user must have needed this");

  nsRefPtr<gfxImageSurface> image = CreateImage();
  if (!image)
    return NS_ERROR_OUT_OF_MEMORY;

  nsRefPtr<gfxASurface> offscreen =
    gfxPlatform::GetPlatform()->CreateOffscreenSurface(
            gfxIntSize(mSurfaceRect.width, mSurfaceRect.height),
            gfxASurface::CONTENT_COLOR_ALPHA);
  if (!offscreen || offscreen->CairoStatus())
    return NS_ERROR_OUT_OF_MEMORY;
  offscreen->SetDeviceOffset(gfxPoint(-mSurfaceRect.x, -mSurfaceRect.y));

  nsRenderingContext tmpCtx;
  tmpCtx.Init(mTargetFrame->PresContext()->DeviceContext(), offscreen);

  gfxRect r = aPrimitive->mImage.mFilterPrimitiveSubregion;
  gfxMatrix m = GetUserSpaceToFilterSpaceTransform();
  m.Invert();
  r = m.TransformBounds(r);

  gfxMatrix deviceToFilterSpace = GetFilterSpaceToDeviceSpaceTransform().Invert();
  gfxContext *gfx = tmpCtx.ThebesContext();
  gfx->Multiply(deviceToFilterSpace);

  gfx->Save();

  gfxMatrix matrix =
    nsSVGUtils::GetCanvasTM(mTargetFrame, nsISVGChildFrame::FOR_PAINTING,
                            mTransformRoot);
  if (!matrix.IsSingular()) {
    gfx->Multiply(matrix);
    gfx->Rectangle(r);
    if ((aPrimitive == &mFillPaint && 
         nsSVGUtils::SetupCairoFillPaint(mTargetFrame, gfx)) ||
        (aPrimitive == &mStrokePaint &&
         nsSVGUtils::SetupCairoStrokePaint(mTargetFrame, gfx))) {
      gfx->Fill();
    }
  }
  gfx->Restore();

  gfxContext copyContext(image);
  copyContext.SetSource(offscreen);
  copyContext.Paint();

  aPrimitive->mImage.mImage = image;
  // color model is PREMULTIPLIED SRGB by default.

  return NS_OK;
}
Ejemplo n.º 30
0
Archivo: icon.c Proyecto: Miteam/jwm
/** Create an icon from XPM image data. */
IconNode *GetDefaultIcon(void)
{
   static const char * const name = "default";
   const unsigned width = 8;
   const unsigned height = 8;
   const unsigned border = 1;
   ImageNode *image;
   IconNode *result;
   unsigned bytes;
   unsigned x, y;

   /* Check if this icon has already been loaded */
   result = FindIcon(name);
   if(result) {
      return result;
   }

   /* Allocate image data. */
   bytes = (width * height + 7) / 8;
   image = CreateImage(width, height, 1);
   memset(image->data, 0, bytes);
#ifdef USE_XRENDER
   image->render = 0;
#endif

   /* Allocate the icon node. */
   result = CreateIcon(image);
   result->name = CopyString(name);
   result->images = image;
   InsertIcon(result);

   /* Draw the icon. */
   for(y = border; y < height - border; y++) {
      const unsigned pixel_left = y * width + border;
      const unsigned pixel_right = y * width + width - 1 - border;
      const unsigned offset_left = pixel_left / 8;
      const unsigned mask_left = 1 << (pixel_left % 8);
      const unsigned offset_right = pixel_right / 8;
      const unsigned mask_right = 1 << (pixel_right % 8);
      image->data[offset_left] |= mask_left;
      image->data[offset_right] |= mask_right;
   }
   for(x = border; x < width - border; x++) {
      const unsigned pixel_top = x + border * width;
      const unsigned pixel_bottom = x + width * (height - 1 - border);
      const unsigned offset_top = pixel_top / 8;
      const unsigned mask_top = 1 << (pixel_top % 8);
      const unsigned offset_bottom = pixel_bottom / 8;
      const unsigned mask_bottom = 1 << (pixel_bottom % 8);
      image->data[offset_top] |= mask_top;
      image->data[offset_bottom] |= mask_bottom;
   }

   return result;
}