<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Flipbook not loading images, image type 1 for jpg not loaded from database]]></title><description><![CDATA[<p dir="auto">Retrieving images from the database seems to be broken in 1.12.4.</p>
<p dir="auto">The query returns:</p>
<blockquote></blockquote>
<p dir="auto">select pv.dataType, pv.pointValue, pva.textPointValueShort, pva.textPointValueLong, pv.ts, pva.sourceType,   pva.sourceId from pointValues pv   left join pointValueAnnotations pva on <a href="http://pv.id" rel="nofollow ugc">pv.id</a> = pva.pointValueId where pv.id=9467</p>
<p dir="auto">DATATYPE:	5<br />
POINTVALUE:   	1<br />
TEXTPOINTVALUESHORT:	9467<br />
TEXTPOINTVALUELONG:	null<br />
TS: 	1342218110819<br />
SOURCETYPE:	null<br />
SOURCEID: 	null</p>
<p dir="auto">The new ImageValue constructor uses the textpointvalueshort of 9467 to determine the filename, and the pointvalue 1 to determine the file extension.</p>
<pre><code>
public class ImageValue extends MangoValue implements Comparable&lt;ImageValue&gt; {
    private static final String FILENAME_PREFIX = "img";

    public static final int TYPE_JPG = 1;
    private static final String[] TYPES = { "", "jpg" };

    private long id = Common.NEW_ID;
    private int type;
    private byte[] data;

    public ImageValue(long id, int type) {
        this.id = id;
        this.type = type;
    }

    public ImageValue(byte[] data, int type) {
        this.data = data;
        this.type = type;
    }
...

</code></pre>
<p dir="auto">Therefore in PointValueDao.java</p>
<pre><code>
    MangoValue createMangoValue(ResultSet rs, int firstParameter) throws SQLException {
        int dataType = rs.getInt(firstParameter);
        MangoValue value;
        switch (dataType) {
        case (DataTypes.NUMERIC):
            value = new NumericValue(rs.getDouble(firstParameter + 1));
            break;
        case (DataTypes.BINARY):
            value = new BinaryValue(rs.getDouble(firstParameter + 1) == 1);
            break;
        case (DataTypes.MULTISTATE):
            value = new MultistateValue(rs.getInt(firstParameter + 1));
            break;
        case (DataTypes.ALPHANUMERIC):
            String s = rs.getString(firstParameter + 2);
            if (s == null)
                s = rs.getString(firstParameter + 3);
            value = new AlphanumericValue(s);
            break;
        case (DataTypes.IMAGE):
            value = new ImageValue(Integer.parseInt(rs.getString(firstParameter + 2)), rs.getInt(firstParameter + 3));
            break;
        default:
            value = null;
        }
        return value;
    }

</code></pre>
<p dir="auto">should be</p>
<pre><code>
...
        case (DataTypes.IMAGE):
            value = new ImageValue(Integer.parseInt(rs.getString(firstParameter + 2)), rs.getInt(firstParameter + 1));

</code></pre>
<p dir="auto">changing the column used to load the image type from the fourth column to the 2nd gives the image the correct type (1 for jpg) and subsequently the correct file extension is used when loading images for the flipbook, otherwise "img9467." is loaded by the imageValueServlet, which doesn't exist, and 0 byte images are returned result.</p>
]]></description><link>https://forum.mango-os.com/topic/1040/flipbook-not-loading-images-image-type-1-for-jpg-not-loaded-from-database</link><generator>RSS for Node</generator><lastBuildDate>Sat, 06 Jun 2026 20:09:36 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/1040.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 14 Jul 2012 02:49:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Flipbook not loading images, image type 1 for jpg not loaded from database on Thu, 19 Jul 2012 00:27:16 GMT]]></title><description><![CDATA[<p dir="auto">Yes, this is the correct fix. It already made it into 1.13.x, but didn't make it back into 1.12.x.</p>
]]></description><link>https://forum.mango-os.com/post/6538</link><guid isPermaLink="true">https://forum.mango-os.com/post/6538</guid><dc:creator><![CDATA[mlohbihler]]></dc:creator><pubDate>Thu, 19 Jul 2012 00:27:16 GMT</pubDate></item></channel></rss>