Skip to content

Commit

Permalink
Prepare for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Jul 3, 2016
1 parent 62c7e4c commit 6319deb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
^src/Makevars$
.travis.yml
appveyor.yml
^windows
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
*.o
*.a
*.so
*.dll
*.png
src/Makevars
windows
Empty file added configure.win
Empty file.
18 changes: 18 additions & 0 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
PKG_CPPFLAGS=-I../windows/imagemagick-7.0.2.2/include/ImageMagick-7
PKG_CXXFLAGS=-DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
CXX_STD=CXX11

PKG_LIBS= -L../windows/imagemagick-7.0.2.2/lib${R_ARCH} \
-lMagick++-7.Q16 -lMagickWand-7.Q16 -lMagickCore-7.Q16 \
-lpng -ljpeg -ltiff -ltiffxx -lfreetype -lharfbuzz \
-llzma -lbz2 -lz -lgdi32 -lws2_32 -lOleAut32

all: clean

clean:
rm -f $(OBJECTS) $(SHLIB)

winlibs: clean
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R"

.PHONY: all winlibs clean
12 changes: 5 additions & 7 deletions src/convert.cc
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#include <Magick++.h>
#include <Rcpp.h>
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;

// [[Rcpp::export]]
Rcpp::RawVector convert_to(Rcpp::RawVector x, Rcpp::String to){
//Magick::InitializeMagick();
Blob input( x.begin(), x.length());
Image image( input );
Blob output;
Magick::Blob input( x.begin(), x.length());
Magick::Image image( input );
Magick::Blob output;
image.magick( to ); // Set JPEG output format
image.write( &output );
Rcpp::RawVector res(output.length());
std::memcpy(res.begin(), output.data(), output.length());
memcpy(res.begin(), output.data(), output.length());
return res;
}

0 comments on commit 6319deb

Please sign in to comment.