Esempio n. 1
0
// Send information about the currently open image to the
// BApplication object so it can send it to the InfoWindow
void
ImageView::UpdateInfoWindow(const BPath &path, BMessage &ioExtension,
	const translator_info &tinfo, BTranslatorRoster *proster)
{
	BMessage msg(M_INFO_WINDOW_TEXT);
	BString bstr;

	bstr = B_TRANSLATE("Image: %1\n"
		"Color Space: %2 (%3)\n"
		"Dimensions: %4 x %5\n"
		"Bytes per Row: %6\n"
		"Total Bytes: %7\n"
		"\nIdentify Info:\n"
		"ID String: %8\n"
		"MIME Type: %9\n"
		"Type: '%10' (%11)\n"
		"Translator ID: %12\n"
		"Group: '%13' (%14)\n"
		"Quality: %15\n"
		"Capability: %16\n"
		"\nExtension Info:\n");
	bstr.ReplaceFirst("%1", path.Path());
	color_space cs = fpbitmap->ColorSpace();
	bstr.ReplaceFirst("%2", get_color_space_name(cs));
	bstr.ReplaceFirst("%3", hex_format(static_cast<uint32>(cs)));
	char str2[127] = { 0 };
	sprintf(str2, "%ld", fpbitmap->Bounds().IntegerWidth() + 1);
	bstr.ReplaceFirst("%4", str2);
	str2[0] = '\0';
	sprintf(str2, "%ld", fpbitmap->Bounds().IntegerHeight() + 1);
	bstr.ReplaceFirst("%5", str2);
	str2[0] = '\0';
	sprintf(str2, "%ld", fpbitmap->BytesPerRow());
	bstr.ReplaceFirst("%6", str2);
	str2[0] = '\0';
	sprintf(str2, "%ld", fpbitmap->BitsLength());
	bstr.ReplaceFirst("%7", str2);
	bstr.ReplaceFirst("%8", tinfo.name);
	bstr.ReplaceFirst("%9", tinfo.MIME);
	bstr.ReplaceFirst("%10", char_format(tinfo.type));
	bstr.ReplaceFirst("%11", hex_format(tinfo.type));
	str2[0] = '\0';
	sprintf(str2, "%ld", tinfo.translator);
	bstr.ReplaceFirst("%12", str2);
	bstr.ReplaceFirst("%13", char_format(tinfo.group));
	bstr.ReplaceFirst("%14", hex_format(tinfo.group));
	str2[0] = '\0';
	sprintf(str2, "%f", tinfo.quality);
	bstr.ReplaceFirst("%15", str2);
	str2[0] = '\0';
	sprintf(str2, "%f", tinfo.capability);
	bstr.ReplaceFirst("%16", str2);

	int32 document_count = 0, document_index = 0;
	// Translator Info
	const char *tranname = NULL, *traninfo = NULL;
	int32 tranversion = 0;

	if (ioExtension.FindInt32("/documentCount", &document_count) == B_OK) {
		BString str = B_TRANSLATE("Number of Documents: %1\n"
			"\nTranslator Used:\n"
			"Name: %2\n"
			"Info: %3\n"
			"Version: %4\n");
		char str2[127] = { 0 };
		sprintf(str2, "%ld", document_count);
		str.ReplaceFirst("%1", str2);
		str.ReplaceFirst("%2", tranname);
		str.ReplaceFirst("%3", traninfo);
		str2[0] = '\0';
		sprintf(str2, "%d", (int)tranversion);
		str.ReplaceFirst("%4", str2);
		bstr.Append(str.String());
	}
	else
		if (ioExtension.FindInt32("/documentIndex", &document_index) == B_OK) {
			BString str = B_TRANSLATE("Selected Document: %1\n"
				"\nTranslator Used:\n"
				"Name: %2\n"
				"Info: %3\n"
				"Version: %4\n");
			char str2[127] = { 0 };
			sprintf(str2, "%ld", document_index);
			str.ReplaceFirst("%1", str2);
			str.ReplaceFirst("%2", tranname);
			str.ReplaceFirst("%3", traninfo);
			str2[0] = '\0';
			sprintf(str2, "%d", (int)tranversion);
			str.ReplaceFirst("%4", str2);
			bstr.Append(str.String());
		}
		else
			if (proster->GetTranslatorInfo(tinfo.translator, &tranname,
				&traninfo, &tranversion) == B_OK) {
					BString str = B_TRANSLATE("\nTranslator Used:\n"
						"Name: %1\n"
						"Info: %2\n"
						"Version: %3\n");
					str.ReplaceFirst("%1", tranname);
					str.ReplaceFirst("%2", traninfo);
					char str2[127] = { 0 };
					sprintf(str2, "%d", (int)tranversion);
					str.ReplaceFirst("%3", str2);
					bstr.Append(str.String());
			}

	// Translator Input / Output Formats
	int32 nins = 0, nouts = 0;
	const translation_format *pins = NULL, *pouts = NULL;
	if (proster->GetInputFormats(tinfo.translator, &pins, &nins) == B_OK) {
		bstr << B_TRANSLATE("\nInput Formats:");
		dump_translation_formats(bstr, pins, nins);
		pins = NULL;
	}
	if (proster->GetOutputFormats(tinfo.translator, &pouts, &nouts) == B_OK) {
		bstr << B_TRANSLATE("\nOutput Formats:");
		dump_translation_formats(bstr, pouts, nouts);
		pouts = NULL;
	}
	msg.AddString("text", bstr);
	be_app->PostMessage(&msg);
}
Esempio n. 2
0
// Send information about the currently open image to the
// BApplication object so it can send it to the InfoWindow
void
ImageView::UpdateInfoWindow(const BPath &path, BMessage &ioExtension,
	const translator_info &tinfo, BTranslatorRoster *proster)
{
	BMessage msg(M_INFO_WINDOW_TEXT);
	BString bstr;
	
	// Bitmap Info
	bstr << "Image: " << path.Path() << "\n";
	color_space cs = fpbitmap->ColorSpace();
	bstr << "Color Space: " << get_color_space_name(cs) << " (" << 
		hex_format(static_cast<uint32>(cs)) << ")\n";
	bstr << "Dimensions: " << fpbitmap->Bounds().IntegerWidth() + 1 << " x " <<
		fpbitmap->Bounds().IntegerHeight() + 1 << "\n";
	bstr << "Bytes per Row: " << fpbitmap->BytesPerRow() << "\n";
	bstr << "Total Bytes: " << fpbitmap->BitsLength() << "\n";
	
	// Identify Info
	bstr << "\nIdentify Info:\n";
	bstr << "ID String: " << tinfo.name << "\n";
	bstr << "MIME Type: " << tinfo.MIME << "\n";
	bstr << "Type: '" << char_format(tinfo.type) << "' (" <<
		hex_format(tinfo.type) << ")\n";
	bstr << "Translator ID: " << tinfo.translator << "\n";
	bstr << "Group: '" << char_format(tinfo.group) << "' (" <<
		hex_format(tinfo.group) << ")\n";
	bstr << "Quality: " << tinfo.quality << "\n";
	bstr << "Capability: " << tinfo.capability << "\n";
	
	// Extension Info
	bstr << "\nExtension Info:\n";
	int32 document_count = 0, document_index = 0;
	if (ioExtension.FindInt32("/documentCount", &document_count) == B_OK)
		bstr << "Number of Documents: " << document_count << "\n";
	if (ioExtension.FindInt32("/documentIndex", &document_index) == B_OK)
		bstr << "Selected Document: " << document_index << "\n";
	
	// Translator Info
	const char *tranname = NULL, *traninfo = NULL;
	int32 tranversion = 0;
	if (proster->GetTranslatorInfo(tinfo.translator, &tranname, &traninfo,
		&tranversion) == B_OK) {
		bstr << "\nTranslator Used:\n";
		bstr << "Name: " << tranname << "\n";
		bstr << "Info: " << traninfo << "\n";
		bstr << "Version: " << tranversion << "\n";
	}
		
	// Translator Input / Output Formats
	int32 nins = 0, nouts = 0;
	const translation_format *pins = NULL, *pouts = NULL;
	if (proster->GetInputFormats(tinfo.translator, &pins, &nins) == B_OK) {
		bstr << "\nInput Formats:";
		dump_translation_formats(bstr, pins, nins);
		pins = NULL;
	}
	if (proster->GetOutputFormats(tinfo.translator, &pouts, &nouts) == B_OK) {
		bstr << "\nOutput Formats:";
		dump_translation_formats(bstr, pouts, nouts);
		pouts = NULL;
	}
	
	msg.AddString("text", bstr);
	be_app->PostMessage(&msg);
}