Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » problem whit load image
problem whit load image [message #490724] Fri, 09 October 2009 20:30 Go to next message
Antonio is currently offline AntonioFriend
Messages: 39
Registered: July 2009
Member
Hi to all, thaks for yours help
i have this problem, i load a image, i use this snipet:

final Canvas canvas = new Canvas(shell,SWT.BORDER |SWT.NO_BACKGROUND |
SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL| SWT.H_SCROLL);
canvas.setLayoutData(new RowData(670,350));

botton.addSelectionListener (new SelectionAdapter () {

public void widgetSelected (SelectionEvent e)
{
String currentDir="c:\\";
FileDialog fileChooser = new FileDialog(s, SWT.OPEN);
fileChooser.setText("Open image file");
fileChooser.setFilterPath(currentDir);
fileChooser.setFilterExtensions(new String[] { "*.gif; *.jpg;
*.png; *.ico; *.bmp" });
fileChooser.setFilterNames(new String[] {"(gif, jpeg, png, ico,
bmp)" });
String filename = fileChooser.open();
currentDir = fileChooser.getFilterPath();
nomeFile=fileChooser.getFileName();
if (filename != null){
srFile=filename;
try{
final Image image=new Image(d,new FileInputStream(filename));
height = image.getBounds().height;
width = image.getBounds().width;
label15_1.setText(Integer.toString(height));
label15_2.setText(Integer.toString(width));

canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
GC gc = new GC(canvas);
gc.drawImage(image,10,50);
}
});
canvas.redraw();

}
catch(FileNotFoundException e1)
{
e1.printStackTrace();
}
}
}

});

i can see the image but don't scroll, you can help me?
best regads
Antonio
Re: problem whit load image [message #491246 is a reply to message #490724] Tue, 13 October 2009 18:44 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
See
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet48.java?view=co .

Grant


"Antonio De Curtis" <adecurtis99@yahoo.it> wrote in message
news:hao6in$l4e$1@build.eclipse.org...
> Hi to all, thaks for yours help
> i have this problem, i load a image, i use this snipet:
>
> final Canvas canvas = new Canvas(shell,SWT.BORDER |SWT.NO_BACKGROUND |
> SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL| SWT.H_SCROLL);
> canvas.setLayoutData(new RowData(670,350));
>
> botton.addSelectionListener (new SelectionAdapter () {
>
> public void widgetSelected (SelectionEvent e)
> {
> String currentDir="c:\\";
> FileDialog fileChooser = new FileDialog(s, SWT.OPEN);
> fileChooser.setText("Open image file");
> fileChooser.setFilterPath(currentDir);
> fileChooser.setFilterExtensions(new String[] { "*.gif; *.jpg;
> *.png; *.ico; *.bmp" });
> fileChooser.setFilterNames(new String[] {"(gif, jpeg, png,
ico,
> bmp)" });
> String filename = fileChooser.open();
> currentDir = fileChooser.getFilterPath();
> nomeFile=fileChooser.getFileName();
> if (filename != null){
> srFile=filename;
> try{
> final Image image=new Image(d,new FileInputStream(filename));
> height = image.getBounds().height;
> width = image.getBounds().width;
> label15_1.setText(Integer.toString(height));
> label15_2.setText(Integer.toString(width));
>
> canvas.addPaintListener(new PaintListener() {
> public void paintControl(PaintEvent e) {
> GC gc = new GC(canvas);
> gc.drawImage(image,10,50);
> }
> });
> canvas.redraw();
>
> }
> catch(FileNotFoundException e1)
> {
> e1.printStackTrace();
> }
> }
> }
>
> });
>
> i can see the image but don't scroll, you can help me?
> best regads
> Antonio
>
Previous Topic:[Printing] Under what circumstances will Printer.startJob(), Printer.startPage() return false?
Next Topic:size och swt labels
Goto Forum:
  


Current Time: Wed Dec 11 06:14:22 GMT 2019

Powered by FUDForum. Page generated in 0.01842 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top