本文整理汇总了C++中magick::Blob::data方法的典型用法代码示例。如果您正苦于以下问题:C++ Blob::data方法的具体用法?C++ Blob::data怎么用?C++ Blob::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类magick::Blob
的用法示例。
在下文中一共展示了Blob::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
}
示例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: 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);
}
示例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: 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);
}
示例6: 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;
}
示例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: 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)));
}
示例12: image
void photoalbum::api::map::map_tile_km(
const jsonrpc::request& request,
jsonrpc::result& result,
sqlite::connection& conn
)
{
const std::string region = request.params().get<std::string>(0);
const int eastings = request.params().get<int>(1);
const int northings = request.params().get<int>(2);
photoalbum::map::tile_data_db data_db;
db::get(
conn,
region,
eastings/10,
northings/10,
data_db
);
try
{
Magick::Image image(Magick::Blob(
reinterpret_cast<const void*>(&(data_db.data[0])),
data_db.data.size()
)
);
Magick::Geometry out_size(
image.size().width()/5,
image.size().height()/5
);
Magick::Image out_image(out_size, Magick::Color(255,255,255));
int off_x = -(out_size.width() * (eastings%5));
int off_y = -(out_size.height() * (4 - (northings%5)));
out_image.composite(image, off_x, off_y);
Magick::Blob blob;
out_image.write(&blob, "PNG");
png_data(result.data()).data() = base64::encode(
reinterpret_cast<const unsigned char*>(blob.data()),
blob.length()
);
}
catch(const std::exception& e)
{
}
}
示例13: 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);
}
}
示例14: rotate
void ImageItem::rotate(short degrees)
{
if (!degrees)
return;
QString file = absoluteFilePath();
Magick::Image image;
image.read(file.toStdString());
image.rotate(degrees);
image.write(file.toStdString());
Magick::Blob buffer;
image.write(&buffer);
QImage thumbnail;
thumbnail.loadFromData((const uchar*) buffer.data(), buffer.length());
thumbnail.save(absoluteThumbPath(), "JPEG");
}
示例15: coverImageBlob
Glib::RefPtr<Gdk::Pixbuf> createCoverPixBufWithOverlay(const AlbumArt& albumArt, int32_t size)
{
try
{
std::stringstream finalGeometry;
finalGeometry << size << "x" << size;
std::stringstream intermediateGeometry;
intermediateGeometry << overlayWidth << "x" << overlayHeight << "!";
std::stringstream albumArtGeometry;
albumArtGeometry << coverWidth << "x" << coverHeight << "!";
Magick::Blob coverImageBlob(&(albumArt.getData().front()), albumArt.getData().size());
Magick::Image coverImage(coverImageBlob);
coverImage.scale(Magick::Geometry(albumArtGeometry.str()));
Magick::Blob cdCaseBlob(cdCaseData, sizeof(cdCaseData));
Magick::Image cdCase(cdCaseBlob, Magick::Geometry(intermediateGeometry.str()), "PNG");
Magick::Quantum maxRgb;
{using namespace Magick; maxRgb = MaxRGB;} // Magick::MaxRGB; quits with the compile-time error "'Quantum' was not declared in this scope"
Magick::Image result(Magick::Geometry(intermediateGeometry.str()), Magick::Color(0, 0, 0, maxRgb));
result.composite(coverImage, coverImageOffsetX, coverImageOffsetY, Magick::CopyCompositeOp);
result.composite(cdCase, 0, 0, Magick::OverCompositeOp);
result.scale(Magick::Geometry(finalGeometry.str()));
Magick::Blob data;
result.write(&data, "PNG");
Glib::RefPtr<Gdk::PixbufLoader> loader = Gdk::PixbufLoader::create();
loader->set_size(size, size);
loader->write((guint8*)data.data(), data.length());
Glib::RefPtr<Gdk::Pixbuf> pixBuf = loader->get_pixbuf();
loader->close();
return pixBuf;
}
catch (Magick::Exception& e)
{
log::warn("Creating cover with overlay failed: %s", e.what());
return createCoverPixBuf(albumArt, size);
}
}