www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - dwt.graphics.ImageLoader.save crashed

reply yidabu <yidabu.spam gmail.com> writes:
when call ImageLoader.save(...), program crashed, 

Code:


import dwt.DWT;
import dwt.graphics.GC;
import dwt.graphics.Image;
import dwt.graphics.ImageData;
import dwt.graphics.ImageLoader;
import dwt.graphics.Rectangle;
import dwt.widgets.Display;
import dwt.widgets.Shell;


void main() {
    Display display = new Display();
    Shell shell = new Shell(display);
    Image image = new Image(display, 640, 480);
    Rectangle rect = image.getBounds();
    GC gc = new GC(image);
    gc.setBackground(display.getSystemColor(DWT.COLOR_RED));
    gc.fillOval(rect.x, rect.y, rect.width, rect.height);
    gc.dispose();
    ImageLoader loader = new ImageLoader();
    loader.data = [image.getImageData()];

    loader.save(r"D:\test.bmp", DWT.IMAGE_BMP); //program crashed here

    shell.setSize(shell.computeSize(rect.width / 2, rect.height / 2));
    shell.setText("saved");
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}




-- 
yidabu <yidabu.spam gmail.com>
http://www.dsource.org/projects/dwin

D ÓïÑÔ-ÖÐÎÄ(D Chinese):
http://www.d-programming-language-china.org/
http://bbs.d-programming-language-china.org/
http://dwin.d-programming-language-china.org/
http://scite4d.d-programming-language-china.org/
Jun 22 2008
parent Frank Benoit <keinfarbton googlemail.com> writes:
yidabu schrieb:
 when call ImageLoader.save(...), program crashed, 
 
 Code:
 
 
 import dwt.DWT;
 import dwt.graphics.GC;
 import dwt.graphics.Image;
 import dwt.graphics.ImageData;
 import dwt.graphics.ImageLoader;
 import dwt.graphics.Rectangle;
 import dwt.widgets.Display;
 import dwt.widgets.Shell;
 
 
 void main() {
     Display display = new Display();
     Shell shell = new Shell(display);
     Image image = new Image(display, 640, 480);
     Rectangle rect = image.getBounds();
     GC gc = new GC(image);
     gc.setBackground(display.getSystemColor(DWT.COLOR_RED));
     gc.fillOval(rect.x, rect.y, rect.width, rect.height);
     gc.dispose();
     ImageLoader loader = new ImageLoader();
     loader.data = [image.getImageData()];
 
     loader.save(r"D:\test.bmp", DWT.IMAGE_BMP); //program crashed here
 
     shell.setSize(shell.computeSize(rect.width / 2, rect.height / 2));
     shell.setText("saved");
     shell.open();
     while (!shell.isDisposed()) {
         if (!display.readAndDispatch())
             display.sleep();
     }
     image.dispose();
     display.dispose();
 }
 
 
 
 
Should work now with dwt-win. Thanks for reporting.
Jun 24 2008