@@ -180,7 +180,7 @@ infobar_status_value_set_array(Infobar *infobar, double *d)
180180typedef struct _PixelUpdate {
181181 // what we update, where we get the pixel data
182182 Infobar * infobar ;
183- Tilesource * tilesource ;
183+ VipsImage * image ;
184184
185185 // fetch params
186186 int image_x ;
@@ -196,7 +196,7 @@ infobar_update_free(PixelUpdate *update)
196196 update -> infobar -> updating = FALSE;
197197
198198 VIPS_UNREF (update -> infobar );
199- VIPS_UNREF (update -> tilesource );
199+ VIPS_UNREF (update -> image );
200200 VIPS_FREE (update -> vector );
201201 VIPS_FREE (update );
202202}
@@ -220,9 +220,22 @@ static void
220220infobar_get_pixel (void * a , void * b )
221221{
222222 PixelUpdate * update = (PixelUpdate * ) a ;
223+ VipsImage * image = update -> image ;
223224
224- update -> result = tilesource_get_pixel (update -> tilesource ,
225- update -> image_x , update -> image_y , & update -> vector , & update -> n );
225+ /* Block outside the image.
226+ */
227+ if (update -> image_x >= 0 &&
228+ update -> image_y >= 0 &&
229+ update -> image_x < image -> Xsize &&
230+ update -> image_y < image -> Ysize )
231+ /* Fetch from image, even though this can be very slow.
232+ * This is run in a bg thread, so speed should not matter too much.
233+ */
234+ update -> result = !vips_getpoint (image ,
235+ & update -> vector , & update -> n ,
236+ update -> image_x , update -> image_y ,
237+ "unpack_complex" , TRUE,
238+ NULL );
226239
227240 g_idle_add (infobar_update_pixel_idle , update );
228241}
@@ -232,18 +245,24 @@ static void
232245infobar_update_pixel (Infobar * infobar ,
233246 Tilesource * tilesource , double image_x , double image_y )
234247{
235- if (!infobar -> updating ) {
236- PixelUpdate * update = g_new0 (PixelUpdate , 1 );
248+ if (!infobar -> updating &&
249+ tilesource -> image ) {
250+ infobar -> updating = TRUE;
237251
252+ PixelUpdate * update = g_new0 (PixelUpdate , 1 );
238253 update -> infobar = infobar ;
239- update -> tilesource = tilesource ;
240- update -> image_x = image_x ;
241- update -> image_y = image_y ;
242- infobar -> updating = TRUE;
254+ update -> image = tilesource -> image ;
255+
256+ /* Currently in level0 image coordinates ... we will fetch from
257+ * tilesource->image, the current pyr layer.
258+ */
259+ int factor = tilesource -> image_width / tilesource -> image -> Xsize ;
260+ update -> image_x = image_x / factor ;
261+ update -> image_y = image_y / factor ;
243262
244263 // must stay valid until we are done
245264 g_object_ref (update -> infobar );
246- g_object_ref (update -> tilesource );
265+ g_object_ref (update -> image );
247266
248267 if (vips_thread_execute ("pixel" , infobar_get_pixel , update ))
249268 // if we can't run a bg task, we must free the update
@@ -266,16 +285,16 @@ infobar_status_update(Infobar *infobar)
266285
267286 Tilesource * tilesource = imagewindow_get_tilesource (infobar -> win );
268287 imagewindow_get_mouse_position (infobar -> win , & image_x , & image_y );
269- image_x = VIPS_CLIP (0 , (int ) image_x , tilesource -> image -> Xsize - 1 );
270- image_y = VIPS_CLIP (0 , (int ) image_y , tilesource -> image -> Ysize - 1 );
271288
272- vips_buf_appendf (& buf , "%d" , (int ) image_x );
273- gtk_label_set_text (GTK_LABEL (infobar -> x ), vips_buf_all (& buf ));
274- vips_buf_rewind (& buf );
289+ if (tilesource -> image ) {
290+ vips_buf_appendf (& buf , "%d" , (int ) image_x );
291+ gtk_label_set_text (GTK_LABEL (infobar -> x ), vips_buf_all (& buf ));
292+ vips_buf_rewind (& buf );
275293
276- vips_buf_appendf (& buf , "%d" , (int ) image_y );
277- gtk_label_set_text (GTK_LABEL (infobar -> y ), vips_buf_all (& buf ));
278- vips_buf_rewind (& buf );
294+ vips_buf_appendf (& buf , "%d" , (int ) image_y );
295+ gtk_label_set_text (GTK_LABEL (infobar -> y ), vips_buf_all (& buf ));
296+ vips_buf_rewind (& buf );
297+ }
279298
280299 double zoom = imagewindow_get_zoom (infobar -> win );
281300 vips_buf_appendf (& buf , "Magnification %d%%" , (int ) rint (zoom * 100 ));
0 commit comments