Skip to main content



      Home
Home » Newcomers » Newcomers » show part of a bitmap
show part of a bitmap [message #253884] Mon, 14 April 2008 13:45 Go to next message
Eclipse UserFriend
Hi
I want to show part of an image as a button image.
is there anybody to help me?
regards
Re: show part of a bitmap [message #253900 is a reply to message #253884] Mon, 14 April 2008 16:46 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:Programmatically create popup
Next Topic:Help - DTP mySQL
Goto Forum:
  


Current Time: Tue Jul 15 08:29:09 EDT 2025

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

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

Back to the top