As suggested by kleopatra I found this solution: The image is put inside a scrollPane and I get the viewable size of the cell by
javax.swing.JComponent.getVisibleRect().getWidth();
where the JPanel is a JComponent... I can't paste more code directly, as we use other frameworks that wrap Swing and I didn't test that directly, sorry. If somebody else has this problem and uses this solution please add low level Swing code, thanks.
Thanks for your suggestions!