Skip to content

Commit

Permalink
stereograma - initial git repository. new SW depth map renderer for 3…
Browse files Browse the repository at this point in the history
…D objects.
  • Loading branch information
gnudles committed Mar 15, 2016
0 parents commit 640c0b2
Show file tree
Hide file tree
Showing 54 changed files with 6,729 additions and 0 deletions.
1,616 changes: 1,616 additions & 0 deletions RPly/rply.c

Large diffs are not rendered by default.

378 changes: 378 additions & 0 deletions RPly/rply.h

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions RPly/rplyfile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#ifndef RPLY_FILE_H
#define RPLY_FILE_H
/* ----------------------------------------------------------------------
* RPly library, read/write PLY files
* Diego Nehab, IMPA
* http://www.impa.br/~diego/software/rply
*
* This library is distributed under the MIT License. See notice
* at the end of this file.
* ---------------------------------------------------------------------- */

#ifdef __cplusplus
extern "C" {
#endif

/* ----------------------------------------------------------------------
* Opens a PLY file for reading (fails if file is not a PLY file)
*
* file_pointer: FILE * to file open for reading
* error_cb: error callback function
* idata,pdata: contextual information available to users
*
* Returns 1 if successful, 0 otherwise
* ---------------------------------------------------------------------- */
p_ply ply_open_from_file(FILE *file_pointer, p_ply_error_cb error_cb,
long idata, void *pdata);

/* ----------------------------------------------------------------------
* Creates new PLY file
*
* file_pointer: FILE * to a file open for writing
* storage_mode: file format mode
* error_cb: error callback function
* idata,pdata: contextual information available to users
*
* Returns handle to PLY file if successfull, NULL otherwise
* ---------------------------------------------------------------------- */
p_ply ply_create_to_file(FILE *file_pointer, e_ply_storage_mode storage_mode,
p_ply_error_cb error_cb, long idata, void *pdata);

#ifdef __cplusplus
}
#endif

#endif /* RPLY_FILE_H */

/* ----------------------------------------------------------------------
* Copyright (C) 2003-2015 Diego Nehab. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ---------------------------------------------------------------------- */
108 changes: 108 additions & 0 deletions anaglyphmaker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#include "anaglyphmaker.h"
#include "imageviewer.h"
#include "ui_anaglyphmaker.h"
#include <QMessageBox>

AnaglyphMaker::AnaglyphMaker(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::AnaglyphMaker)
{
ui->setupUi(this);
ui->rightView->setBasicImageParent(this);
ui->rightView->setFolderSettings("anaglyph");
ui->rightView->setSaveTitle("Right Image");
ui->leftView->setBasicImageParent(this);
ui->leftView->setFolderSettings("anaglyph");
ui->leftView->setSaveTitle("Left Image");
}

AnaglyphMaker::~AnaglyphMaker()
{
delete ui;
}

void AnaglyphMaker::on_mergeButton_clicked()
{
if (ui->leftView->getImage().isNull() || ui->rightView->getImage().isNull())
{
QMessageBox::warning(this,"Error","Please load images");
return;
}
if ((ui->leftView->getImage().width() != ui->rightView->getImage().width())
|| (ui->leftView->getImage().height() != ui->rightView->getImage().height()))
{
QMessageBox::warning(this,"Error","Images are not at the same size.");
return;
}
int width = ui->leftView->getImage().width();
int height = ui->leftView->getImage().height();

const QImage * refLeft=ui->leftView->getImagePtr();
const QImage * refRight=ui->rightView->getImagePtr();
if (ui->swapButton->isChecked())
{
const QImage *temp=refLeft;
refLeft=refRight;
refRight=temp;
}
QImage imLeft,imRight;
if (ui->leftView->getImage().depth()!=32)
imLeft=refLeft->convertToFormat(QImage::Format_ARGB32);
else
imLeft=*refLeft;

if (ui->rightView->getImage().depth()!=32)
imRight=refRight->convertToFormat(QImage::Format_ARGB32);
else
imRight=*refRight;

QImage result(width,height,QImage::Format_ARGB32);
unsigned int *resptr;
unsigned int *endptr;
const unsigned int *leftptr;
const unsigned int *rightptr;
unsigned int rightalpha,leftalpha;
unsigned int alpha;
unsigned int r,g,b;
for (int i=0;i<height;i++)
{
resptr=(unsigned int *)result.scanLine(i);
endptr=resptr+width;
leftptr=(const unsigned int *)imLeft.scanLine(i);
rightptr=(const unsigned int *)imRight.scanLine(i);
while(resptr<endptr)
{
rightalpha=((*rightptr)&0xff000000)>>24;
leftalpha=((*leftptr)&0xff000000)>>24;
r=((*leftptr)&0x00ff0000)>>16;
g=((*rightptr)&0x0000ff00)>>8;
b=((*rightptr)&0x000000ff);
alpha = leftalpha+rightalpha-rightalpha*leftalpha/255;
if (alpha==0)
{
*resptr=0;
resptr++;
rightptr++;
leftptr++;
}
else
{
r=(unsigned char)((leftalpha*r)/(alpha));

g=(unsigned char)((rightalpha*g)/(alpha));

b=(unsigned char)((rightalpha*b)/(alpha));
*resptr=(alpha<<24)|(r<<16)|(g<<8)|b;
resptr++;
rightptr++;
leftptr++;
}
}
}
ImageViewer * imview=new ImageViewer(this);
imview->setWindowTitle("Result");
imview->setFolderSettings("anaglyph_result");
imview->setSaveTitle("Anaglyph");
imview->setImage(result);
imview->show();
}
25 changes: 25 additions & 0 deletions anaglyphmaker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef ANAGLYPHMAKER_H
#define ANAGLYPHMAKER_H

#include <QMainWindow>

namespace Ui {
class AnaglyphMaker;
}

class AnaglyphMaker : public QMainWindow
{
Q_OBJECT

public:
explicit AnaglyphMaker(QWidget *parent = 0);
~AnaglyphMaker();

private slots:
void on_mergeButton_clicked();

private:
Ui::AnaglyphMaker *ui;
};

#endif // ANAGLYPHMAKER_H
Loading

0 comments on commit 640c0b2

Please sign in to comment.