本文整理汇总了C++中magick::Blob类的典型用法代码示例。如果您正苦于以下问题:C++ Blob类的具体用法?C++ Blob怎么用?C++ Blob使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Blob类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printAlt
void Night::printAlt (int year, int month, int day, XmlRpc::HttpParams *params, const char* &response_type, char* &response, size_t &response_length)
{
response_type = "image/jpeg";
AltPlot ap (params->getInteger ("w", 800), params->getInteger ("h", 600));
Magick::Geometry size (params->getInteger ("w", 800), params->getInteger ("h", 600));
time_t from;
int64_t duration;
getNightDuration (year, month, day, from, duration);
time_t end = from + duration;
rts2db::ImageSetDate is = rts2db::ImageSetDate (from, end);
is.load ();
Magick::Image mimage (size, "white");
ap.getPlot (from, end, &is, &mimage);
Magick::Blob blob;
mimage.write (&blob, "jpeg");
response_length = blob.length();
response = new char[response_length];
memcpy (response, blob.data(), response_length);
}
示例2: load
//----------------------------------------------------------------------------------------------------------------------
// Image Magick Image loading routines
//----------------------------------------------------------------------------------------------------------------------
bool Image::load( const std::string &_fname ) noexcept
{
#ifdef IMAGE_DEBUG_ON
std::cerr<<"loading with ImageMagick"<<std::endl;
#endif
Magick::Image image;
Magick::Blob blob;
try
{
image.read(_fname);
// need to flip image as OpenGL uses textures starting the other way round.
image.flip();
image.write(&blob, "RGBA");
}
catch (Magick::Error& Error)
{
std::cout << "Error loading texture '" << _fname << "': " << Error.what() << std::endl;
return false;
}
m_width=image.columns();
m_height=image.rows();
m_channels=4;
m_format=GL_RGBA;
m_data.reset(new unsigned char[ m_width*m_height*m_channels]);
// simple memcpy of the blob data to our internal data, not worrying about RGB/RGBA
// here (as OpenGL doesn't really either).
memcpy(m_data.get(),blob.data(),blob.length());
return true;
}
示例3: plotTarget
void Targets::plotTarget (rts2db::Target *tar, XmlRpc::HttpParams *params, const char* &response_type, char* &response, size_t &response_length)
{
response_type = "image/jpeg";
AltPlot ap (params->getInteger ("w", 800), params->getInteger ("h", 600));
Magick::Geometry size (params->getInteger ("w", 800), params->getInteger ("h", 600));
double from = params->getDouble ("from", 0);
double to = params->getDouble ("to", 0);
if (from < 0 && to == 0)
{
// just fr specified - from
to = time (NULL);
from += to;
}
else if (from == 0 && to == 0)
{
// default - one day
to = time (NULL);
from = to - 86400;
}
Magick::Image mimage (size, "white");
ap.getPlot (from, to, tar, &mimage);
Magick::Blob blob;
mimage.write (&blob, "jpeg");
response_length = blob.length();
response = new char[response_length];
memcpy (response, blob.data(), response_length);
}
示例4: osra_cuneiform_ocr
char osra_cuneiform_ocr(Magick::Image &cuneiform_img, const string &char_filter)
{
Magick::Blob blob;
cuneiform_img.write(&blob, "DIB");
size_t data_size = blob.length();
char *dib = new char[data_size];
memcpy(dib, blob.data(), data_size);
char str[256];
memset(str, 0, sizeof(str));
if (!PUMA_XOpen(dib, NULL) || !PUMA_XFinalRecognition() || !PUMA_SaveToMemory(NULL, PUMA_TOTEXT, PUMA_CODE_ASCII, str, sizeof(str) - 1))
{
//if (verbose)
// cout << "Cuneiform recognition failed." << endl;
PUMA_XClose();
delete []dib;
return UNKNOWN_CHAR;
}
PUMA_XClose();
delete []dib;
// As we have initialized the image with two identical samples, it is expected that they go in the string
// one after another, or separated by space (e.g. "ZZ\n" or "Z Z\n").
if (((str[0] == str[1] && isspace(str[2])) || (str[0] == str[2] && str[1] == ' ')) && isalnum(str[0])
&& (char_filter.empty() || char_filter.find(str[0], 0) != string::npos))
return str[0];
return UNKNOWN_CHAR;
}
示例5: magick_image_write
// [[Rcpp::export]]
Rcpp::RawVector magick_image_write( XPtrImage input, Rcpp::CharacterVector format, Rcpp::IntegerVector quality,
Rcpp::IntegerVector depth, Rcpp::CharacterVector density, Rcpp::CharacterVector comment){
if(!input->size())
return Rcpp::RawVector(0);
XPtrImage image = copy(input);
#if MagickLibVersion >= 0x691
//suppress write warnings see #74 and #116
image->front().quiet(true);
#endif
if(format.size())
for_each ( image->begin(), image->end(), Magick::magickImage(std::string(format[0])));
if(quality.size())
for_each ( image->begin(), image->end(), Magick::qualityImage(quality[0]));
if(depth.size())
for_each ( image->begin(), image->end(), Magick::depthImage(depth[0]));
if(density.size()){
for_each ( image->begin(), image->end(), Magick::resolutionUnitsImage(Magick::PixelsPerInchResolution));
for_each ( image->begin(), image->end(), Magick::densityImage(Point(density[0])));
}
if(comment.size())
for_each ( image->begin(), image->end(), Magick::commentImage(std::string(comment.at(0))));
Magick::Blob output;
writeImages( image->begin(), image->end(), &output );
Rcpp::RawVector res(output.length());
std::memcpy(res.begin(), output.data(), output.length());
return res;
}
示例6: onInput
void PipelineStabDetect::onInput(InputImageInfo info, Magick::Image image) {
try {
if (!initialized) {
init(image);
}
if (image.rows() != height || image.columns() != width) {
throw runtime_error(QString("Not uniform image size! %").arg(info.file.fileName()).toStdString());
}
Magick::Blob blob;
// set raw RGBS output format & convert it into a Blob
if (image.depth() > 8)
*err << "Warning: we lost some information by converting to 8bit depth (now " << image.depth() << ")" << endl;
image.depth(8);
image.magick("RGB");
image.write(&blob);
LocalMotions localmotions;
VSFrame frame;
size_t dataLen = blob.length();
Q_ASSERT(fi.planes == 1);
Q_ASSERT(dataLen == image.baseColumns() * image.baseRows() * 3);
if (stabConf->mdConf.show > 0) { // create copy of blob
frame.data[0] = new uint8_t[dataLen];
memcpy(frame.data[0], blob.data(), dataLen);
} else {
frame.data[0] = (uint8_t*) blob.data();
}
frame.linesize[0] = image.baseColumns() * 3;
if (vsMotionDetection(&md, &localmotions, &frame) != VS_OK) {
throw runtime_error("motion detection failed");
} else {
if (vsWriteToFile(&md, f, &localmotions) != VS_OK) {
throw runtime_error("cannot write to transform file");
}
vs_vector_del(&localmotions);
}
if (stabConf->mdConf.show > 0) {
// if we want to store transformations, we have to create new image...
Magick::Geometry g(width, height);
Magick::Blob oblob(frame.data[0], dataLen);
Magick::Image oimage;
oimage.read(oblob, g, 8, "RGB");
delete[] frame.data[0];
emit input(info, oimage);
} else {
emit input(info, image);
}
} catch (exception &e) {
emit error(e.what());
}
}
示例7: Write
void FsImgStorage::Write(ImgInfo& img) const {
Utils::Contract::Assert(img.GetId() != IMGID_UNDEFINED);
Utils::Contract::Assert(!img.GetFileExtension().empty());
boost::filesystem::path uploadFilePath = GetImgPath(img.GetId(), img.GetFileExtension());
Magick::Blob magickBlob;
img.GetMagickImage().write(&magickBlob);
Utils::FileSystem::WriteAllBytes((const char*)magickBlob.data(), magickBlob.length(), uploadFilePath);
}
示例8: main
int main ( int argc, char **argv )
{
int i; /* loop iterator */
int height, width; /* image dimensions */
string param; /* passed parameter */
void *raw_data; /* raw image data */
Magick::Blob blob; /* image in blob format */
vector <string> qr_data; /* decoded qr codes */
/* Check that a file was passed - provide usage statement if not */
if( argc != 2 )
{
error( TRUE, "Usage: read_img (imagefile | 'webcam')" );
}
/* get command line arg as c++ style string */
param = argv[ 1 ];
/* process the image into the raw data */
if( param == "webcam" )
{
/* obtain the image from the webcam */
dbg_msg( "Attempting to get data from webcam using OpenCV" );
get_cam_img( raw_data, width, height );
}
else
{
/* initalize image magick c++ library and use it to get image data */
dbg_msg( "Using ImageMagick to read QR codes from image file %s", param.c_str() );
Magick::InitializeMagick( NULL );
read_img( param, blob, width, height );
raw_data = (void *) blob.data();
}
/* process the qr codes */
if( raw_data == NULL )
{
error( TRUE, "Could not read image data" );
}
get_codes( qr_data, raw_data, width, height );
/* output all of the recognized codes */
for( i = 0; i < qr_data.size(); i++ )
{
printf( "symbol %d - data: %s\n", i, qr_data[ i ].c_str() );
}
/* be tidy -- don't leak memory */
if( raw_data != NULL && param == "webcam" ) free( raw_data );
return 0;
}
示例9: processForm
void Targets::processForm (XmlRpc::HttpParams *params, const char* &response_type, char* &response, size_t &response_length)
{
#ifdef RTS2_HAVE_LIBJPEG
if (!strcmp (params->getString ("plot", "xxx"), "Plot target altitude"))
{
response_type = "image/jpeg";
AltPlot ap (params->getInteger ("w", 800), params->getInteger ("h", 600));
Magick::Geometry size (params->getInteger ("w", 800), params->getInteger ("h", 600));
double from = params->getDouble ("from", 0);
double to = params->getDouble ("to", 0);
if (from < 0 && to == 0)
{
// just fr specified - from
to = time (NULL);
from += to;
}
else if (from == 0 && to == 0)
{
// default - one hour
to = time (NULL);
from = to - 86400;
}
std::list < int > ti;
for (XmlRpc::HttpParams::iterator iter = params->begin (); iter != params->end (); iter++)
{
if (!strcmp (iter->getName (), "tid"))
ti.push_back (atoi (iter->getValue ()));
}
rts2db::TargetSet ts = rts2db::TargetSet ();
ts.load (ti);
Magick::Image mimage (size, "white");
ap.getPlot (from, to, &ts, &mimage);
Magick::Blob blob;
mimage.write (&blob, "jpeg");
response_length = blob.length();
response = new char[response_length];
memcpy (response, blob.data(), response_length);
return;
}
#endif // RTS2_HAVE_LIBJPEG
}
示例10: magick_image_write_integer
// [[Rcpp::export]]
Rcpp::IntegerVector magick_image_write_integer(XPtrImage input){
if(input->size() != 1)
throw std::runtime_error("Image must have single frame to write a native raster");
Frame frame = input->front();
Magick::Geometry size(frame.size());
size_t width = size.width();
size_t height = size.height();
Magick::Blob output;
frame.write(&output, "RGBA", 8L);
Rcpp::IntegerVector res(output.length() / 4);
memcpy(res.begin(), output.data(), output.length());
res.attr("class") = Rcpp::CharacterVector::create("nativeRaster");
res.attr("dim") = Rcpp::NumericVector::create(height, width);
return res;
}
示例11: load
bool CubemapTexture::load() {
Magick::Image *img;
Magick::Blob blob;
glGenTextures(1, &_tex);
glBindTexture(GL_TEXTURE_CUBE_MAP, _tex);
for (uint i=0; i < sizeof(types) / sizeof(types[0]); i++) {
img = new Magick::Image(_fs[i]);
try {
img->write(&blob, "RGBA");
} catch (Magick::Error &err) {
std::cerr << "Could not load texture " << _fs[i] << ": " << err.what() << std::endl;
delete (img);
return false;
}
std::cout << "Cubemap texture loaded: " << _fs[i] << std::endl;
glTexImage2D(types[i], 0, GL_RGB, img->columns(), img->rows(), 0, GL_RGBA, GL_UNSIGNED_BYTE, blob.data());
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
delete img;
}
return true;
}
示例12: lResult
ItemSequence_t
FormatFunction::evaluate(
const ExternalFunction::Arguments_t& aArgs,
const StaticContext* aSctxCtx,
const DynamicContext* aDynCtx) const
{
Magick::Image lImage;
ImageFunction::getOneImageArg(aDynCtx, aArgs, 0, lImage);
Magick::Blob lBlob;
lImage.write(&lBlob);
long lBlobLength = (long) lBlob.length();
std::string lImageType = GetImageType(lBlob.data(), &lBlobLength);
String lResult(lImageType);
return ItemSequence_t(new SingletonItemSequence(
theModule->getItemFactory()->createString(lResult)));
}
示例13: Load
bool CubemapTexture::Load()
{
glGenTextures(1, &m_textureObj);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_textureObj);
Magick::Image* pImage = NULL;
Magick::Blob blob;
for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(types) ; i++) {
pImage = new Magick::Image(m_fileNames[i]);
try {
pImage->write(&blob, "RGBA");
}
catch (Magick::Error& Error) {
cout << "Error loading texture '" << m_fileNames[i] << "': " << Error.what() << endl;
delete pImage;
return false;
}
glTexImage2D(types[i], 0, GL_RGB, pImage->columns(), pImage->rows(), 0, GL_RGBA, GL_UNSIGNED_BYTE, blob.data());
delete pImage;
}
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
return true;
}
示例14: updateNoCopy_wrapper
void updateNoCopy_wrapper(Magick::Blob& blob, std::string& data) {
std::string str;
char* w = new char[data.size() + 1];
std::copy(str.begin(), str.end(), w);
w[str.size()] = '\0';
blob.updateNoCopy(w,data.size(),Magick::Blob::NewAllocator);
}
示例15: target
ResizeTest(std::string fileName) {
source.loadFile(fileName);
for (int i=1; i<99; ++i) {
Magick::Image image = source.getImage();
image.magick("JPEG");
image.quality(50);
Magick::Geometry resizeGeometry;
resizeGeometry.percent(true);
resizeGeometry.width(i);
resizeGeometry.height(i);
image.resize(resizeGeometry);
Magick::Blob blob;
image.write(&blob);
imghash::Source target((char*)blob.data(), blob.length());
images.push_back(target);
}
}