正如标题所说,我想在移动 jslider 时非常快速地检索图像(存储在 longblob 中)。我有 360 个案例,并且可以正常工作,但问题在于移动 jslider 时每个案例/图像的滞后/延迟。我用从本地机器检索的图像测试了这个想法,它工作得非常快/干净。我知道问题可能出在互联网连接上,但相信我,我至少有 3-4 MB/s 的下载/上传速度。
一些额外的注释:表引擎:MyISAM 列:longblob,每张图像 ~170-200 kb - .png
//calling jslider and setup
jslider1 = new javax.swing.JSlider(); //my jslider
jslider1.setMajorTickSpacing(10);
jslider1.setMaximum(360);
jslider1.setMinorTickSpacing(5);
jslider1.setOrientation(javax.swing.JSlider.VERTICAL);
//and my change event
private void jslider1StateChanged(javax.swing.event.ChangeEvent evt) {
int x = jslider1.getValue();
switch (x) {
case 1:
try {
String sql = "select imga from test where deg ='" + x + "'";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
if (rs.next()) {
byte[] imagedata = rs.getBytes("imga");
format = new ImageIcon(imagedata);
jLabel1.setIcon(format); //where I put my image
}
} catch (Exception e) {
e.printStackTrace();
}
break;
case 2:
//[...] //I have 360 cases
}
} // close state changed