Código:
#include <windows.h>
#include "ximage.h"
#include "stdafx.h"
#pragma comment(lib,"CxImage.lib")
#pragma comment(lib,"jpeg.lib")
int main()
{
CxImage image;
// bmp -> jpg
image.Load("d:\\image.bmp", CXIMAGE_FORMAT_BMP);
if (image.IsValid())
{
if(!image.IsGrayScale()) image.IncreaseBpp(24);
image.SetJpegQuality(70);
image.Save("d:\\image.jpg",CXIMAGE_FORMAT_JPG);
}
// jpg -> bmp
image.Load("d:\\image.jpg", CXIMAGE_FORMAT_JPG);
if (image.IsValid())
{
if(!image.IsGrayScale()) image.IncreaseBpp(24);
image.Save("d:\\image2.bmp",CXIMAGE_FORMAT_BMP);
}
}
// redimensionner + bmp -> jpg
image.Load("d:\\image.bmp", CXIMAGE_FORMAT_BMP);
if (image.IsValid())
{
image.Resample(1024/2,768/2,1,0);
image.Save("d:\\imagesize.jpg",CXIMAGE_FORMAT_JPG);
}
return 1;
}
Errores:
Citar
--------------------Configuration: convertir - Win32 Debug--------------------
Compiling...
convertir.cpp
D:\visual\convertir\convertir.cpp(12) : error C2065: 'CxImage' : undeclared identifier
D:\visual\convertir\convertir.cpp(12) : error C2146: syntax error : missing ';' before identifier 'image'
D:\visual\convertir\convertir.cpp(12) : error C2065: 'image' : undeclared identifier
D:\visual\convertir\convertir.cpp(15) : error C2228: left of '.Load' must have class/struct/union type
D:\visual\convertir\convertir.cpp(15) : error C2065: 'CXIMAGE_FORMAT_BMP' : undeclared identifier
D:\visual\convertir\convertir.cpp(16) : error C2228: left of '.IsValid' must have class/struct/union type
D:\visual\convertir\convertir.cpp(18) : error C2228: left of '.IsGrayScale' must have class/struct/union type
D:\visual\convertir\convertir.cpp(18) : error C2228: left of '.IncreaseBpp' must have class/struct/union type
D:\visual\convertir\convertir.cpp(19) : error C2228: left of '.SetJpegQuality' must have class/struct/union type
D:\visual\convertir\convertir.cpp(20) : error C2228: left of '.Save' must have class/struct/union type
D:\visual\convertir\convertir.cpp(20) : error C2065: 'CXIMAGE_FORMAT_JPG' : undeclared identifier
D:\visual\convertir\convertir.cpp(25) : error C2228: left of '.Load' must have class/struct/union type
D:\visual\convertir\convertir.cpp(26) : error C2228: left of '.IsValid' must have class/struct/union type
D:\visual\convertir\convertir.cpp(28) : error C2228: left of '.IsGrayScale' must have class/struct/union type
D:\visual\convertir\convertir.cpp(28) : error C2228: left of '.IncreaseBpp' must have class/struct/union type
D:\visual\convertir\convertir.cpp(29) : error C2228: left of '.Save' must have class/struct/union type
D:\visual\convertir\convertir.cpp(34) : error C2228: left of '.Load' must have class/struct/union type
D:\visual\convertir\convertir.cpp(35) : error C2228: left of '.IsValid' must have class/struct/union type
D:\visual\convertir\convertir.cpp(37) : error C2228: left of '.Resample' must have class/struct/union type
D:\visual\convertir\convertir.cpp(38) : error C2228: left of '.Save' must have class/struct/union type
Error executing cl.exe.
convertir.exe - 20 error(s), 0 warning(s)
Compiling...
convertir.cpp
D:\visual\convertir\convertir.cpp(12) : error C2065: 'CxImage' : undeclared identifier
D:\visual\convertir\convertir.cpp(12) : error C2146: syntax error : missing ';' before identifier 'image'
D:\visual\convertir\convertir.cpp(12) : error C2065: 'image' : undeclared identifier
D:\visual\convertir\convertir.cpp(15) : error C2228: left of '.Load' must have class/struct/union type
D:\visual\convertir\convertir.cpp(15) : error C2065: 'CXIMAGE_FORMAT_BMP' : undeclared identifier
D:\visual\convertir\convertir.cpp(16) : error C2228: left of '.IsValid' must have class/struct/union type
D:\visual\convertir\convertir.cpp(18) : error C2228: left of '.IsGrayScale' must have class/struct/union type
D:\visual\convertir\convertir.cpp(18) : error C2228: left of '.IncreaseBpp' must have class/struct/union type
D:\visual\convertir\convertir.cpp(19) : error C2228: left of '.SetJpegQuality' must have class/struct/union type
D:\visual\convertir\convertir.cpp(20) : error C2228: left of '.Save' must have class/struct/union type
D:\visual\convertir\convertir.cpp(20) : error C2065: 'CXIMAGE_FORMAT_JPG' : undeclared identifier
D:\visual\convertir\convertir.cpp(25) : error C2228: left of '.Load' must have class/struct/union type
D:\visual\convertir\convertir.cpp(26) : error C2228: left of '.IsValid' must have class/struct/union type
D:\visual\convertir\convertir.cpp(28) : error C2228: left of '.IsGrayScale' must have class/struct/union type
D:\visual\convertir\convertir.cpp(28) : error C2228: left of '.IncreaseBpp' must have class/struct/union type
D:\visual\convertir\convertir.cpp(29) : error C2228: left of '.Save' must have class/struct/union type
D:\visual\convertir\convertir.cpp(34) : error C2228: left of '.Load' must have class/struct/union type
D:\visual\convertir\convertir.cpp(35) : error C2228: left of '.IsValid' must have class/struct/union type
D:\visual\convertir\convertir.cpp(37) : error C2228: left of '.Resample' must have class/struct/union type
D:\visual\convertir\convertir.cpp(38) : error C2228: left of '.Save' must have class/struct/union type
Error executing cl.exe.
convertir.exe - 20 error(s), 0 warning(s)
lo q me pasa es obvio, no encuentra la clase 'CxImage' , pero yo baje el codigo de Cximage, lo compile con visual c++ 6, cree el .lib, incluia todas las funciones q aparecen ahi, lo puse en la carpeta y lo linkie, con el jpeg.lib lo mismo hice, pero no anda y no se q pasa.
y con dev-c++ creo q no se puede linkear a un .lib no? solo a un .a? alguien me lo puede confirmar.