Hola que tal, estoy tratando de probar código que me permite visualizar una imagen *.tiff utilizando visual studio 2013 con las librerías de libtiff y sdl solo que al querer compilar me manda este error "error LNK1561: se debe definir el punto
de entrada" y no es posible compilar ni probar el código.
Copie los archivos de las librerías "lib" a la ruta "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib"
y los archivos "include" a la carpeta "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include"
agregue las librerías en en vinculador "propiedades del proyecto - vinculador - entrada -dependencias adicionales" agregando "libtiff.lib y sdl.lib"
el código que estoy utilizando es el siguiente.
Si pueden apoyarme por favor.
#include<iostream>
#include<tiffio.h>
#include<SDL.h>
using std::endl;
using std::cout;
using std::cerr;
#define DEPTH 16
#define TITLE "Tiff viewer"
void loadTIFF(char* aImageName);
void viewTIFF();
void initGraphMode();
void putPixel(int x, int y, int r, int g, int b);
void lock();
void unlock();
void eventHandler();
bool keyboardEventHandler(SDL_Event e);
SDL_Surface *screen;
uint32* buffer;
uint32 width;
uint32 height;
uint32 npixels;
char pixelValueR, pixelValueG, pixelValueB, pixelValueA;
int main(int argc, char** argv)
{
if (argc != 2) {
cerr << "ERROR: Usage: " << argv[0] << " <image name>" << endl;
exit(1);
}
loadTIFF(argv[1]);
initGraphMode();
viewTIFF();
SDL_UpdateRect(screen, 0, 0, 0, 0);
SDL_Flip(screen);
eventHandler();
SDL_Quit();
}
void loadTIFF(char* aImageName) {
TIFF* img;
cout << "Loading image: " << aImageName << endl;
//Open
if ((img = TIFFOpen(aImageName, "r")) == NULL) {
cerr << "Could not open incoming image" << endl;
exit(101);
}
cout << "Image loaded." << endl;
TIFFGetField(img, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(img, TIFFTAG_IMAGELENGTH, &height);
cout << "Width: " << width << endl;
cout << "Height: " << height << endl;
npixels = width*height;
buffer = (uint32*)_TIFFmalloc(npixels*sizeof(uint32));
if (TIFFReadRGBAImage(img, width, height, buffer, 0) == 0) {
cerr << "Has ocurred any error in read proccess" << endl;
exit(102);
}
cout << "Closing image." << endl;
TIFFClose(img);
}
void viewTIFF() {
uint32 y = -1;
uint32 x = 0;
cout << "Processing buffer." << endl;
for (int i = 0; i<npixels; i++) {
if (i % width == 0) y++;
x = i - width*y;
pixelValueR = (char)TIFFGetR(buffer[i]);
pixelValueG = (char)TIFFGetG(buffer[i]);
pixelValueB = (char)TIFFGetB(buffer[i]);
putPixel(x, height - y - 1,
pixelValueR,
pixelValueG,
pixelValueB);
}
_TIFFfree(buffer);
}
void initGraphMode()
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
cout << "Error inittializaing SDL: " << SDL_GetError() << endl;
exit(1);
}
screen = SDL_SetVideoMode(width, height, DEPTH, SDL_HWSURFACE | SDL_DOUBLEBUF);
if (screen == NULL)
{
cout << "Error stablishing video mode: " << SDL_GetError() << endl;
}
SDL_WM_SetCaption(TITLE, NULL);
}
void putPixel(int x, int y, int r, int g, int b)
{
lock();
Uint32 color;
Uint8* buffer;
if (screen != NULL)
{
color = SDL_MapRGB(screen->format, r, g, b);
buffer = (Uint8*)screen->pixels + y * screen->pitch + screen->format->BytesPerPixel * x;
memcpy(buffer, &color, screen->format->BytesPerPixel);
}
unlock();
}
void lock()
{
if (SDL_MUSTLOCK(screen))
SDL_LockSurface(screen);
}
void unlock()
{
if (SDL_MUSTLOCK(screen))
SDL_UnlockSurface(screen);
}
void eventHandler()
{
SDL_Event event;
bool exit = false;
do
{
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
exit = true;
break;
case SDL_KEYDOWN:
exit = keyboardEventHandler(event);
break;
}
}
} while (!exit);
}
bool keyboardEventHandler(SDL_Event e)
{
bool quit = false;
switch (e.key.keysym.sym)
{
case SDLK_f:
SDL_WM_ToggleFullScreen(screen);
break;
case SDLK_q:
quit = true;
break;
}
return quit;
}