/* Required Identify function - may need to read entire header, not sure */ status_t Identify(BPositionIO *inSource, const translation_format *inFormat, BMessage *ioExtension, translator_info *outInfo, uint32 outType) { const char *debug_text = getenv("GIF_TRANSLATOR_DEBUG"); if ((debug_text != NULL) && (atoi(debug_text) != 0)) debug = true; if (outType == 0) outType = B_TRANSLATOR_BITMAP; if (outType != GIF_TYPE && outType != B_TRANSLATOR_BITMAP) return B_NO_TRANSLATOR; bool is_gif; if (!DetermineType(inSource, &is_gif)) return B_NO_TRANSLATOR; if (!is_gif && inFormat != NULL && inFormat->type != B_TRANSLATOR_BITMAP) return B_NO_TRANSLATOR; outInfo->group = B_TRANSLATOR_BITMAP; if (is_gif) { outInfo->type = GIF_TYPE; outInfo->quality = 0.8; outInfo->capability = 0.8; strlcpy(outInfo->name, B_TRANSLATE("GIF image"), sizeof(outInfo->name)); strcpy(outInfo->MIME, "image/gif"); } else { outInfo->type = B_TRANSLATOR_BITMAP; outInfo->quality = 0.3; outInfo->capability = 0.3; strlcpy(outInfo->name, B_TRANSLATE("Be Bitmap Format (GIFTranslator)"), sizeof(outInfo->name)); strcpy(outInfo->MIME, "image/x-be-bitmap"); } return B_OK; }
ConfigContent::ConfigContent(QObject *parent, QString config_name, QStringList tags_to_process) : QObject(parent), content_widget_(new QWidget()), config_name_(config_name), tags_to_process_(tags_to_process), type_(Unknown) { DetermineType(config_name); }
void iCover::ReadContents(Util::Stream& stream) { m_children = MPEG4_Parser::ParseBoxes(stream, m_bodySize); ARC_ASSERT_MSG(m_children.size() > 0, "iAlbum box with no data!"); if (m_children.size() > 0) { std::vector<unsigned char>& data = *dynamic_pointer_cast<DataBox>(m_children[0])->GetData(); // first 8 bytes of the data are skipped. m_imageData = data.begin() + 8; m_imageDataSize = m_children[0]->GetSize() - 8; // now determine the type m_type = DetermineType(m_imageData); } }
/* Main required function - assumes that an incoming GIF must be translated to a BBitmap, and vice versa - this could be improved */ status_t Translate(BPositionIO *inSource, const translator_info *inInfo, BMessage *ioExtension, uint32 outType, BPositionIO *outDestination) { const char *debug_text = getenv("GIF_TRANSLATOR_DEBUG"); if ((debug_text != NULL) && (atoi(debug_text) != 0)) debug = true; if (outType == 0) outType = B_TRANSLATOR_BITMAP; if (outType != GIF_TYPE && outType != B_TRANSLATOR_BITMAP) { return B_NO_TRANSLATOR; } bool is_gif; if (!DetermineType(inSource, &is_gif)) return B_NO_TRANSLATOR; if (!is_gif && inInfo->type != B_TRANSLATOR_BITMAP) return B_NO_TRANSLATOR; status_t err = B_OK; bigtime_t now = system_time(); // Going from BBitmap to GIF if (!is_gif) { BBitmap *bitmap = NULL; err = GetBitmap(inSource, &bitmap); if (err != B_OK) return err; GIFSave *gs = new GIFSave(bitmap, outDestination); if (gs->fatalerror) { delete gs; delete bitmap; return B_NO_MEMORY; } delete gs; delete bitmap; } else { // GIF to BBitmap GIFLoad *gl = new GIFLoad(inSource, outDestination); if (gl->fatalerror) { delete gl; return B_NO_MEMORY; } delete gl; } if (debug) { now = system_time() - now; syslog(LOG_ERR, "Translate() - Translation took %Ld microseconds\n", now); } return B_OK; }
/*! Main required function - assumes that an incoming GIF must be translated to a BBitmap, and vice versa - this could be improved */ status_t GIFTranslator::DerivedTranslate(BPositionIO* inSource, const translator_info* inInfo, BMessage* ioExtension, uint32 outType, BPositionIO* outDestination, int32 baseType) { const char* debug_text = getenv("GIF_TRANSLATOR_DEBUG"); if (debug_text != NULL && atoi(debug_text) != 0) debug = true; if (outType == 0) outType = B_TRANSLATOR_BITMAP; if (outType != GIF_TYPE && outType != B_TRANSLATOR_BITMAP) return B_NO_TRANSLATOR; bool isGif; if (!DetermineType(inSource, &isGif)) return B_NO_TRANSLATOR; if (!isGif && inInfo->type != B_TRANSLATOR_BITMAP) return B_NO_TRANSLATOR; status_t result = B_OK; bigtime_t now = system_time(); if (!isGif) { // BBitmap to GIF BBitmap* bitmap; result = GetBitmap(inSource, &bitmap); if (result != B_OK) return result; GIFSave* gifSave = new(std::nothrow) GIFSave(bitmap, outDestination, fSettings); if (gifSave == NULL) { delete bitmap; return B_NO_MEMORY; } if (gifSave->fatalerror) { delete gifSave; delete bitmap; return B_NO_MEMORY; } delete gifSave; delete bitmap; } else { // GIF to BBitmap GIFLoad* gifLoad = new(std::nothrow) GIFLoad(inSource, outDestination); if (gifLoad == NULL) return B_NO_MEMORY; if (gifLoad->fatalerror) { delete gifLoad; return B_NO_MEMORY; } delete gifLoad; } if (debug) { now = system_time() - now; syslog(LOG_INFO, "Translate() - Translation took %Ld microseconds\n", now); } return B_OK; }
Instruction::Instruction(const std::string& id) : Instruction(DetermineType(id)) { }