|
Re: show part of a bitmap [message #253900 is a reply to message #253884] |
Mon, 14 April 2008 16:46  |
Eclipse User |
|
|
|
There are two ways that I can think of. One is to crop the image
yourself and do a setImage() on the button. The other is to just draw
the button yourself. The second option looks a little something like
this:
public void createPartControl(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
panel.setLayout(new RowLayout());
ImageData[] data = new ImageLoader()
.load("/home/wayne/Pictures/Image000.jpg");
final Image image = new Image(parent.getDisplay(), data[0]);
Button button = new Button(panel, SWT.PUSH);
button.setLayoutData(new RowData(200, 75));
button.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.drawImage(image, 0, 0, 25, 25, 10, 10, 25, 25);
}
});
button.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
image.dispose();
}
});
}
(don't forget to dispose the image)
HTH,
Wayne
On Mon, 2008-04-14 at 17:45 +0000, Mostafa wrote:
> Hi
> I want to show part of an image as a button image.
> is there anybody to help me?
> regards
>
|
|
|
Powered by
FUDForum. Page generated in 0.09356 seconds