Exemplo n.º 1
0
unsigned char* QuicktimeImportExport::pepareBufferForOSG(unsigned char * buffer, int bytesPerPixel, unsigned int width, unsigned int height)
{
    unsigned char *pixels = new unsigned char [height * width * 4];
    unsigned char *dstp = pixels;
    unsigned char *srcp = buffer;
    unsigned int i, j;
    
    int roffset, goffset, boffset, aoffset;
    aoffset = -1;
    int sourceStep;
    
    switch (bytesPerPixel) {
        case 1:
            sourceStep = 1;
            roffset = goffset = boffset = 0;
            break;
        case 3:
            sourceStep = 3;
            roffset = 0;
            goffset = 1;
            boffset = 2;
            break;
        case 4:
            sourceStep = 4;
            aoffset = 1;
            roffset = 2;
            goffset = 3;
            boffset = 0;
            break;
            
    }
                    
    for (i = 0; i < height; ++i ) 
    {
        for (j = 0; j < width; ++j ) 
        {
            dstp[0] = (aoffset < 0) ? 0 : srcp[aoffset];
            dstp[1] = srcp[roffset];
            dstp[2] = srcp[goffset];
            dstp[3] = srcp[boffset];
            srcp+=sourceStep;
            dstp+=4;
            
        }
    }
    
    flipImage(pixels, bytesPerPixel, width, height);
    return pixels;

}
Exemplo n.º 2
0
GLuint loadCubemapCross(char *filename)
{
    Image *cross = loadPPM(filename);
    if (!cross) {
        return 0;
    }
    flipImage(cross);

    Image *faces[6];
    bool success = convertCrossToCubemap(cross, faces);
    if (success) {
        GLuint tex = createCubemapTexture(faces);
        return tex;
    }

    return 0;
}
Exemplo n.º 3
0
static void noddrawUpdateFrame(void)
{
    BITMAPINFOHEADER* pbi;
    BITMAPINFO bmi;
    BITMAPINFO* pbmi;
    HBITMAP hbitmap;
    BYTE* pbits;
    WORD* pbitmap;
    HDC hdc, hdcTemp;
    int bitsize;

    flipImage();

    pbmi = &bmi;

    bitsize = 2 * SCRWIDTH * SCRHEIGHT;
    pbits = (BYTE*)scratch_buffer_2;

    pbi = (BITMAPINFOHEADER*)pbmi;
    pbi->biSize = sizeof(BITMAPINFOHEADER);
    pbi->biWidth = SCRWIDTH;
    pbi->biHeight = SCRHEIGHT;
    pbi->biPlanes = 1;
    pbi->biBitCount = 16;
    pbi->biCompression = BI_RGB;
    pbi->biSizeImage = 0;
    pbi->biXPelsPerMeter = 0;
    pbi->biYPelsPerMeter = 0;
    pbi->biClrUsed = 0;
    pbi->biClrImportant = 0;

    hdc = GetDC(hwnd);
    hbitmap = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (VOID**)&pbitmap, 0, 0);
    SetDIBits(hdc, hbitmap, 0, SCRHEIGHT, pbits, pbmi, DIB_RGB_COLORS);

    hdcTemp = CreateCompatibleDC(hdc);
    SelectObject(hdcTemp, hbitmap);

    BitBlt(hdc, 0, 0, SCRWIDTH, SCRHEIGHT, hdcTemp, 0, 0, SRCCOPY);

    DeleteDC(hdcTemp);
    ReleaseDC(hwnd, hdc);

    DeleteObject(hbitmap);
}
Exemplo n.º 4
0
GLuint loadCubemap(char *filenameFormat)
{
    // load faces
    Image *faces[6];
    for(int i=0; i<6; i++) {
        char filename[256];
        sprintf(filename, filenameFormat, i+1);
        faces[i] = loadPPM(filename);
		if (!faces[i])
			return 0;
        flipImage(faces[i]);
    }

    GLuint tex = createCubemapTexture(faces);

    for(int i=0; i<6; i++) {
        free(faces[i]->data);
        free(faces[i]);
    }

    return tex;
}
Exemplo n.º 5
0
Arquivo: main.c Projeto: erosalain23/c
int main(int argc, const char * argv[]) {
    
    int width,height,numPixels,i,rgb_color=255;
    char c,choice;
    
    FILE * inFile;
    inFile = fopen("Android_robot.png","r");
    
    c=getc(inFile);
    while(c=='#')
    {
        do
        {
            c=getc(inFile);
        }while (c!='\n');
        c=getc(inFile);
    }
    ungetc(c, inFile);
    
    // gusoma width na height birimuri  iyo file
    if(fscanf(inFile,"P6 %d %d",&width,&height)!=2)
    {
        fprintf(stderr, "invalid image size. \n");
        exit(1);
    }
    // gusoma RGB color components
    if(fscanf(inFile, "%d\n",&rgb_color)!=1)
    {
        fprintf(stderr, "invalid RGB color component. \n");
        exit(1);
    }
    //gucheckinga RGB deth niba ingana na yayindi twa defininze hejuru
    if(rgb_color!=RGB_COLOR)
    {
        fprintf(stderr, "Invalid RBG value.\n");
        exit(1);
    }
    
    //gushaka number of pixels zirimo
    numPixels = width*height;
    
    //kw allocatinga space ingana na number of pixels
    image = malloc(numPixels * sizeof(pixel_t));
    
    // ku readinga data ziri muri pixel
    for(i=0;i<numPixels;i++)
    {
        fscanf(inFile, "%c%c%c",&image[i].r,&image[i].g,&image[i].b);
    }
    
    // new header
    printf("P6\n");
    printf("%d %d 255\n",width,height);
    
    printf(" choose 1.filp image 2.grascale 3.rotate image .\n");
    scanf("%c",&choice);
    switch (choice) {
        case '1':
            flipImage(image,width, height);
            break;
        case '2':
            grayscale(image, width, height);
            break;
        case '3':
            //rotate(image, width, height);
            break;
        default:
            printf("invalid command");
            break;
    }
    return 0;
}
Exemplo n.º 6
0
GLWidget::GLWidget ( QWidget *parent , bool allow_qpainter_overlay) : QGLWidget ( allow_qpainter_overlay ? QGLFormat(QGL::SampleBuffers) : QGLFormat(), parent ) {
  ALLOW_QPAINTER=allow_qpainter_overlay;
  rb_bb=0;
  rb=0;
  stack=0;
  setAutoFillBackground(false);
  //not needed because we are remote triggering this:
  //startTimer(1);

  /*setMinimumSize ( 60,40 );
  colorPicker=new ColorPicker();
  actionColorPicker=new QWidgetAction ( this );
  actionColorPicker->setDefaultWidget ( ( QWidget * ) colorPicker );
  actionColorPicker->setVisible ( true );
  actionColorPicker->setToolTip ( "RGB Color Picker\n(Left click in image to use)" );
  addAction ( actionColorPicker );*/

  QAction * actionSave = new QAction ( this );
  actionSave->setObjectName ( "actionSave" );
  actionSave->setIcon ( QIcon ( ":/icons/document-save.png" ) );
  actionSave->setShortcut ( QKeySequence ( "Ctrl+s" ) );
  actionSave->setToolTip ( "Save Image... (Ctrl-s)" );
  actionSave->setShortcutContext ( Qt::WidgetShortcut );
  addAction ( actionSave );


  actionFlipV = new QAction ( this );
  actionFlipV->setObjectName ( "actionFlipV" );
  actionFlipV->setToolTip ( "Flip image vertically" );
  actionFlipV->setCheckable ( true );
  actionFlipV->setIcon ( QIcon ( ":/icons/delete_table_row.png" ) );
  addAction ( actionFlipV );

  actionFlipH = new QAction ( this );
  actionFlipH->setObjectName ( "actionFlipH" );
  actionFlipH->setToolTip ( "Flip image horizontally" );
  actionFlipH->setCheckable ( true );
  actionFlipH->setIcon ( QIcon ( ":/icons/delete_table_col.png" ) );
  addAction ( actionFlipH );

  QAction * actionHelp = new QAction ( this );
  actionHelp->setObjectName ( "actionHelp" );
  actionHelp->setIcon ( QIcon ( ":/icons/help-contents.png" ) );
  actionHelp->setShortcut ( QKeySequence ( "Ctrl+h" ) );
  actionHelp->setToolTip ( "Show keyboard shortcuts (Ctrl-h)" );
  actionHelp->setShortcutContext ( Qt::WidgetShortcut );
  addAction ( actionHelp );

  QAction * actionZoomFit = new QAction ( this );
  actionZoomFit->setObjectName ( "actionZoomFit" );
  actionZoomFit->setIcon ( QIcon ( ":/icons/zoom-best-fit.png" ) );
  actionZoomFit->setShortcut ( QKeySequence ( "Space" ) );
  actionZoomFit->setToolTip ( "Zoom to Fit (Space)" );
  actionZoomFit->setShortcutContext ( Qt::WidgetShortcut );
  addAction ( actionZoomFit );

  QAction * actionZoomNormal = new QAction ( this );
  actionZoomNormal->setObjectName ( "actionZoomNormal" );
  actionZoomNormal->setIcon ( QIcon ( ":/icons/zoom-original.png" ) );
  actionZoomNormal->setShortcut ( QKeySequence ( "Home" ) );
  actionZoomNormal->setShortcutContext ( Qt::WidgetShortcut );
  actionZoomNormal->setToolTip ( "Zoom to 100% (Home)" );
  addAction ( actionZoomNormal );

  actionOn = new QAction ( this );
  actionOn->setObjectName ( "actionOn" );
  actionOn->setCheckable ( true );
  actionOn->setChecked ( true );
  actionOn->setShortcut ( QKeySequence ( "Ctrl+p" ) );
  actionOn->setShortcutContext ( Qt::WidgetShortcut );
  actionOn->setToolTip ( "Turn display on/off (Ctrl-p)" );
  actionOn->setIcon ( QIcon ( ":/icons/application-exit.png" ) );
  addAction ( actionOn );

  connect ( actionSave, SIGNAL ( triggered() ), this, SLOT ( saveImage() ) );
  connect ( actionFlipV, SIGNAL ( triggered ( bool ) ), this, SLOT ( flipImage() ) );
  connect ( actionFlipH, SIGNAL ( triggered ( bool ) ), this, SLOT ( flipImage() ) );
  connect ( actionHelp, SIGNAL ( triggered() ), this, SLOT ( callHelp() ) );
  connect ( actionZoomFit, SIGNAL ( triggered() ), this, SLOT ( callZoomFit() ) );
  connect ( actionZoomNormal, SIGNAL ( triggered() ), this, SLOT ( callZoomNormal() ) );


  flipImage();
}
Exemplo n.º 7
0
Arquivo: main.c Projeto: dyjhhh/dong28
int main(int argc,char *argv[])
{
  //Handles user input
  if(argc<4 || argc>5)
  {
    printf("Incorrect number of arguments\n");
    printf("Number of arguments: %d\n",argc);
    exit(1);
  }

  //const char *inputFilename=argv[1];
  const char *inputFilename=argv[1];
  printf("Inputfile: %s\n",inputFilename);
  const char *outputFilename=argv[2];
  char garbage[2];
  int command;
  double sigma=3;

  if(1!=sscanf(argv[3],"%d%1s",&command,garbage) || command<0 || command>11)
  {
    printf("Incorrect command\n");
    exit(1);
  }

  if(command>0 && command<11 && argc==5)
  {
    printf("Incorrect number of arguments, exclude the sigma value");
    exit(1);
  }

  if(((command==0 || command==11) && argc==5 && 1!=sscanf(argv[4],"%lf%1s",&sigma,garbage)) || sigma<0)
  {
    printf("Incorrect sigma value\n");
    exit(1);
  }

  Filter *filters=initializeFilters(sigma);
  Image *inputImage=decode(inputFilename);
  printf("Width: %d, height: %d\n",inputImage->width,inputImage->height);
  Image *outputImage=generateOutput(inputImage);

  uint8_t *inRed=inputImage->redChannel;
  uint8_t *inBlue=inputImage->blueChannel;
  uint8_t *inGreen=inputImage->greenChannel;
  uint8_t *inAlpha=inputImage->alphaChannel;
  uint8_t *outRed=outputImage->redChannel;
  uint8_t *outBlue=outputImage->blueChannel;
  uint8_t *outGreen=outputImage->greenChannel;
  uint8_t *outAlpha=outputImage->alphaChannel;
  int height=inputImage->height;
  int width=inputImage->width;
  switch(command)
  {
    case(0):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[0].filter,filters[0].radius,width,height);
      break;
    }
    case(1):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[1].filter,filters[1].radius,width,height);
      break;
    }
    case(2):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[2].filter,filters[2].radius,width,height);
      break;
    }
    case(3):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[3].filter,filters[3].radius,width,height);
      break;
    }
    case(4):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[4].filter,filters[4].radius,width,height);
      break;
    }
    case(5):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[5].filter,filters[5].radius,width,height);
      break;
    }
    case(6):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[6].filter,filters[6].radius,width,height);
      break;
    }
    case(7):
    {
      convertToGray(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,gMonoMult,width,height);
      break;
     }
    case(8):
    {
      invertImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                  outAlpha,width,height);
      break;
    }
    case(9):
    {
      flipImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                outAlpha,width,height);
      break;
    }
    case(10):
    {
      pixelate(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
               outAlpha,8,8,width,height);
      break;
    }
    case(11):
    {
      Image *invImage=generateOutput(inputImage);
      Image *blurImage=generateOutput(inputImage);
      pencilSketch(inRed,inBlue,inGreen,inAlpha,invImage->redChannel,
                   invImage->blueChannel,invImage->greenChannel,
                   invImage->alphaChannel,blurImage->redChannel,
                   blurImage->blueChannel,blurImage->greenChannel,
                   blurImage->alphaChannel,outRed,outBlue,outGreen,
                   outAlpha,filters[0].filter,filters[0].radius,width,height,
                   gMonoMult);
      //NOTE THAT I NEED TO FREE EACH OF THE CHANNEL INDIVIDUALLY
      //MAKE A FREE IMAGE FUNCTION
      freeImage(invImage);
      freeImage(blurImage);
      break;
    }
    default:
      exit(1);
  }

  if(command!=12)
    encode(outputFilename,outputImage);

  free((double*)filters[0].filter);
  free(filters);
  freeImage(inputImage);
  freeImage(outputImage);
  return 0;
}
Exemplo n.º 8
0
bool TF::Texture::SetTexels(void* texels, u32 miplevel, TextureFace face)
{
	if ( miplevel >= mipLevels )
		return false;

	bool success = true;

	u32 div = 1 << miplevel; // 2 ^ miplevel
	GLsizei w = width / div; if ( w == 0 ) w = 1;
	GLsizei h = height / div; if ( h == 0 ) h = 1;
	GLsizei d = depth / div; if ( d == 0 ) d = 1;
	
	// defined in Renderer.cpp
	void GetOpenGLParametersFromTextureFormat(TextureFormat format, GLint& glInternalFormat, GLenum& glFormat, GLenum& glType, bool& isCompressed);
	
	GLint glInternalFormat = 0;
	GLenum glFormat = 0;
	GLenum glType = 0;
	bool isCompressed;
	GetOpenGLParametersFromTextureFormat(format, glInternalFormat, glFormat, glType, isCompressed);

	// flip texture vertically since OpenGL starts at lower left corner...
	if ( type == TT_TEXTURE2D || type == TT_TEXTURECUBE )
	{
		flipImage(texels, w, h, format);
	}

	// upload texture to pbo
	u32 nbBytes = ComputeTextureMemorySize(type, format, w, h, d);
	glBindBuffer(GL_PIXEL_UNPACK_BUFFER, specific.pbo);
	glBufferData(GL_PIXEL_UNPACK_BUFFER, nbBytes, 0, GL_STREAM_DRAW);
	glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, nbBytes, texels);

	if ( glGetError() )
	{
		LOGWARNING("Failed to upload to PBO.");
		success = false;
		goto fail;
	}

	// send to video memory
	switch ( type )
	{
		case TT_TEXTURE1D:
		{
			TF_ASSERT(format < TFMT_BC1);
			glBindTexture(GL_TEXTURE_1D, specific.texture);
			glTexImage1D(GL_TEXTURE_1D, miplevel, glInternalFormat, w, 0, glFormat, glType, 0);
			break;
		}

		case TT_SHADOW:
		case TT_TEXTURE2D:
		case TT_TEXTURECUBE:
		{
			GLenum target = type == TT_TEXTURECUBE ? GL_TEXTURE_CUBE_MAP_POSITIVE_X + face : GL_TEXTURE_2D;
			glBindTexture(target, specific.texture);
			if ( isCompressed )
			{
				u32 nbBytes = ComputeTextureMemorySize(type, format, w, h);
				glCompressedTexImage2D(target, miplevel, glInternalFormat, w, h, 0, nbBytes, 0);
			}
			else
			{
				glTexImage2D(target, miplevel, glInternalFormat, w, h, 0, glFormat, glType, 0);
			}
			break;
		}

		case TT_TEXTURE3D:
		{
			TF_ASSERT(format < TFMT_BC1);
			glBindTexture(GL_TEXTURE_3D, specific.texture);
			glTexImage3D(GL_TEXTURE_3D, miplevel, glInternalFormat, w, h, d, 0, glFormat, glType, 0);
			break;
		}
	}

	if ( glGetError() )
	{
		LOGWARNING("Failed to upload texels.");
		success = false;
		goto fail;
	}

	glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);

fail:
	// restore texture
	if ( type == TT_TEXTURE2D || type == TT_TEXTURECUBE )
	{
		flipImage(texels, w, h, format);
	}

	return success;
}
Exemplo n.º 9
0
void ImageTransformation::writeImages(Mat imageBase, QString destinationPath, QString fileName, QString extension, MainWindow* mainW)
{

    Mat imageTemp;
    imageBase.copyTo(imageTemp);

    Mat imageRotate0 = imageTemp;
    Mat imageRotate90;
    Mat imageRotate180;
    Mat imageRotate270;

    if (mainW->bResizeChecked)
    {
        int width = mainW->iWidth;
        int height = mainW->iHeight;
        resize(imageTemp,imageTemp,Size(width,height), 0, 0, INTER_CUBIC);

        imwrite((destinationPath + "/" + resizesPath + fileName + extension).toStdString(), imageTemp );

        LogImgDataset::getInstance().Log(INFO, "Resize image");
    }

    if (mainW->bRotateChecked)
    {
        //Rotate Images 0 - 90 - 180 -270
        imageRotate0 = imageTemp;
        imageRotate90 = rotateImage(imageTemp, 90.0);
        imageRotate180 = rotateImage(imageTemp, 180.0);
        imageRotate270 = rotateImage(imageTemp, 270.0);

        imwrite((destinationPath + "/" + rotateImagesPath + fileName + extension).toStdString(), imageRotate0 );
        imwrite((destinationPath + "/" + rotateImagesPath + fileName + "_R90" + extension).toStdString(), imageRotate90 );
        imwrite((destinationPath + "/" + rotateImagesPath + fileName + "_R180" + extension).toStdString(), imageRotate180 );
        imwrite((destinationPath + "/" + rotateImagesPath + fileName + "_R270" + extension).toStdString(), imageRotate270 );

        LogImgDataset::getInstance().Log(INFO, "Rotate images: 0 - 90 - 180 - 270");

        if (mainW->bFlipChecked)
        {
            //Vertical Flip in Rotate Images
            Mat imageFlipV0 = flipImage(imageRotate0, 1);
            Mat imageFlipV90 = flipImage(imageRotate90, 1);
            Mat imageFlipV180 = flipImage(imageRotate180, 1);
            Mat imageFlipV270 = flipImage(imageRotate270, 1);

            imwrite((destinationPath + "/" + rotateImagesPath + fileName + "_F0" + extension).toStdString(), imageFlipV0 );
            imwrite((destinationPath + "/" + rotateImagesPath + fileName + "_F90" + extension).toStdString(), imageFlipV90 );
            imwrite((destinationPath + "/" + rotateImagesPath + fileName + "_F180" + extension).toStdString(), imageFlipV180 );
            imwrite((destinationPath + "/" + rotateImagesPath + fileName + "_F270" + extension).toStdString(), imageFlipV270 );

            LogImgDataset::getInstance().Log(INFO, "Fliping ...");
        }

    }
    else if (mainW->bFlipChecked)
    {
        //Vertical Flip in Rotate Images
        Mat imageFlipV0 = flipImage(imageRotate0, 1);
        imwrite((destinationPath + "/" + rotateImagesPath + fileName + "_F0" + extension).toStdString(), imageFlipV0 );

        LogImgDataset::getInstance().Log(INFO, "Fliping ...");
    }

}
Exemplo n.º 10
0
void ImageTransformation::writeImages(vector<coordinateInfo> coordinates, Mat imageBase, QString destinationPath, QString fileName, QString extension, MainWindow* mainW)
{

    ///Crop the interest area
    for (uint j=0; j < coordinates.size(); j++)
    {
        QString number = "_" + QString::number(j);

        Mat imageRotate0;
        Mat imageRotate90;
        Mat imageRotate180;
        Mat imageRotate270;

        Mat imageTemp;
        imageBase.copyTo(imageTemp);

        if (mainW->bResizeChecked)
        {
            int iWidth = mainW->iWidth;
            int iHeight = mainW->iHeight;
            resize(imageTemp,imageTemp,Size(iWidth,iHeight), 0, 0, INTER_CUBIC);

            imwrite((destinationPath + "/" + resizesPath + fileName + extension).toStdString(), imageTemp );

            LogImgDataset::getInstance().Log(INFO, "Resize image");
        }

        if (mainW->bCropChecked)
        {

            if (mainW->iWindowSize < imageTemp.cols && mainW->iWindowSize < imageTemp.rows)
            {
                if ( coordinates[j].x <= imageTemp.cols && coordinates[j].y <= imageTemp.rows)
                {
                    //Recorte da imagem a partir dos dados dos CSVs
                    QString number = "_" + QString::number(j);
                    Mat imageCrop = cropImage(imageBase, Point(coordinates[j].x,coordinates[j].y), cv::Size(mainW->iWindowSize,mainW->iWindowSize), mainW->iOffset);
                    imwrite((destinationPath + "/" + cropPath + fileName + number + extension).toStdString(), imageCrop);
                    imageTemp = imageCrop;

                    LogImgDataset::getInstance().Log(INFO, "Crop image");
                } else
                {
                    LogImgDataset::getInstance().Log(ERROR, "Crop image failed");
                    LogImgDataset::getInstance().Log(ERROR, "The crop is out of range of the image");
                }
            } else
            {
                LogImgDataset::getInstance().Log(ERROR, "Crop image failed");
                LogImgDataset::getInstance().Log(ERROR, "The window size is bigger than image size.");
            }

        }

        if (mainW->bRotateChecked)
        {
            //Rotate Images 0 - 90 - 180 -270
            imageRotate0 = imageTemp;
            imageRotate90 = rotateImage(imageTemp, 90.0);
            imageRotate180 = rotateImage(imageTemp, 180.0);
            imageRotate270 = rotateImage(imageTemp, 270.0);

            imwrite((destinationPath + "/" + rotateImagesPath + fileName + number + extension).toStdString(), imageRotate0 );
            imwrite((destinationPath + "/" + rotateImagesPath +  fileName + number + "_R90" + extension).toStdString(), imageRotate90 );
            imwrite((destinationPath + "/" + rotateImagesPath +  fileName + number + "_R180" + extension).toStdString(), imageRotate180 );
            imwrite((destinationPath + "/" + rotateImagesPath +  fileName + number + "_R270" + extension).toStdString(), imageRotate270 );

            LogImgDataset::getInstance().Log(INFO, "Rotate images: 0 - 90 - 180 - 270");

            if (mainW->bFlipChecked)
            {
                //Vertical Flip in Rotate Images
                Mat imageFlipV0 = flipImage(imageRotate0, 1);
                Mat imageFlipV90 = flipImage(imageRotate90, 1);
                Mat imageFlipV180 = flipImage(imageRotate180, 1);
                Mat imageFlipV270 = flipImage(imageRotate270, 1);

                imwrite((destinationPath + "/" + rotateImagesPath +  fileName + number + "_F0" + extension).toStdString(), imageFlipV0 );
                imwrite((destinationPath + "/" + rotateImagesPath +  fileName + number + "_F90" + extension).toStdString(), imageFlipV90 );
                imwrite((destinationPath + "/" + rotateImagesPath +  fileName + number + "_F180" + extension).toStdString(), imageFlipV180 );
                imwrite((destinationPath + "/" + rotateImagesPath +  fileName + number + "_F270" + extension).toStdString(), imageFlipV270 );

                LogImgDataset::getInstance().Log(INFO, "Fliping ...");
            }

        }
        else if (mainW->bFlipChecked)
        {
            //Vertical Flip in Rotate Images
            Mat imageFlipV0 = flipImage(imageRotate0, 1);
            imwrite((destinationPath + "/" + rotateImagesPath +  fileName + number + "_F0" + extension).toStdString(), imageFlipV0 );

            LogImgDataset::getInstance().Log(INFO, "Fliping ...");

        }

    }
}
Exemplo n.º 11
0
static int loadSprite(char *name)
{
	int i, x, y, w, h, read, alpha;
	char filename[MAX_FILE_LENGTH];

	read = sscanf(name, "%s %d %d %d %d %d\n", filename, &x, &y, &w, &h, &alpha);

	for (i=0;i<spriteID;i++)
	{
		if (strcmpignorecase(filename, sprite[i].name) == 0)
		{
			return i;
		}
	}

	sprite[spriteID].image = loadImage(filename);

	STRNCPY(sprite[spriteID].name, filename, MAX_FILE_LENGTH);

	if (read == 5)
	{
		sprite[spriteID].box.x = x;
		sprite[spriteID].box.y = y;
		sprite[spriteID].box.w = w;
		sprite[spriteID].box.h = h;
	}

	else
	{
		sprite[spriteID].box.x = 0;
		sprite[spriteID].box.y = 0;
		sprite[spriteID].box.w = sprite[spriteID].image->w;
		sprite[spriteID].box.h = sprite[spriteID].image->h;
	}

	i = spriteID;

	spriteID++;

	sprite[spriteID].image = flipImage(sprite[spriteID - 1].image);

	STRNCPY(sprite[spriteID].name, filename, MAX_FILE_LENGTH);

	if (read == 5)
	{
		sprite[spriteID].box.x = x;
		sprite[spriteID].box.y = y;
		sprite[spriteID].box.w = w;
		sprite[spriteID].box.h = h;
	}

	else
	{
		sprite[spriteID].box.x = 0;
		sprite[spriteID].box.y = 0;
		sprite[spriteID].box.w = sprite[spriteID].image->w;
		sprite[spriteID].box.h = sprite[spriteID].image->h;
	}

	spriteID++;

	return i;
}