Commit 0860db16 authored by twanvl's avatar twanvl

use ->toImage() instead of image_from_script function.

parent f3aac625
......@@ -183,7 +183,7 @@ void DropDownChoiceListBase::generateThumbnailImages() {
try {
String name = canonical_name_form(field().choices->choiceName(i));
ctx.setVariable(_("input"), to_script(name));
GeneratedImageP img = image_from_script(style().image.getValidScriptP()->eval(ctx));
GeneratedImageP img = style().image.getValidScriptP()->eval(ctx)->toImage();
style().choice_images.insert(make_pair(name, ScriptableImage(img)));
} catch (const Error& e) {
handle_error(Error(e.what() + _("\n while generating choice images for drop down list")));
......
......@@ -421,7 +421,7 @@ SCRIPT_FUNCTION(write_image_file) {
if (card) {
image = conform_image(export_bitmap(ei.set, card->getValue()).ConvertToImage(), options);
} else {
image = image_from_script(input)->generateConform(options);
image = input->toImage()->generateConform(options);
}
if (!image.Ok()) throw Error(_("Unable to generate image for file ") + file);
// write
......
......@@ -25,10 +25,6 @@ void parse_enum(const String&, ImageCombine& out);
// ----------------------------------------------------------------------------- : Utility
template <> inline GeneratedImageP from_script<GeneratedImageP>(const ScriptValueP& value) {
return image_from_script(value);
}
SCRIPT_FUNCTION(to_image) {
SCRIPT_PARAM_C(GeneratedImageP, input);
return input;
......@@ -156,7 +152,7 @@ SCRIPT_FUNCTION(symbol_variation) {
} else if (valueO) {
throw ScriptErrorConversion(valueO->typeName(), _TYPE_("symbol" ));
} else {
filename = from_script<String>(symbol);
filename = symbol->toString();
}
// known variation?
SCRIPT_OPTIONAL_PARAM_(String, variation)
......
......@@ -15,13 +15,6 @@
#include <gfx/generated_image.hpp>
#include <data/field/image.hpp>
// ----------------------------------------------------------------------------- : Utility
// convert any script value to a GeneratedImageP
GeneratedImageP image_from_script(const ScriptValueP& value) {
return value->toImage();
}
// ----------------------------------------------------------------------------- : ScriptableImage
Image ScriptableImage::generate(const GeneratedImage::Options& options) const {
......@@ -50,7 +43,7 @@ ImageCombine ScriptableImage::combine() const {
bool ScriptableImage::update(Context& ctx) {
if (!isScripted()) return false;
GeneratedImageP new_value = image_from_script(script.invoke(ctx));
GeneratedImageP new_value = script.invoke(ctx)->toImage();
if (!new_value || !value || *new_value != *value) {
value = new_value;
return true;
......
......@@ -71,9 +71,6 @@ class ScriptableImage {
/// Missing for now
inline ScriptValueP to_script(const ScriptableImage&) { return script_nil; }
/// Convert a script value to a GeneratedImageP
GeneratedImageP image_from_script(const ScriptValueP& value);
// ----------------------------------------------------------------------------- : CachedScriptableImage
/// A version of ScriptableImage that does caching
......
......@@ -429,6 +429,7 @@ template <> inline bool from_script<bool> (const ScriptValueP& va
template <> inline Color from_script<Color> (const ScriptValueP& value) { return value->toColor(); }
template <> inline AColor from_script<AColor> (const ScriptValueP& value) { return value->toColor(); }
template <> inline wxDateTime from_script<wxDateTime> (const ScriptValueP& value) { return value->toDateTime(); }
template <> inline GeneratedImageP from_script<GeneratedImageP>(const ScriptValueP& value) { return value->toImage(); }
// ----------------------------------------------------------------------------- : EOF
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment