Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Save modified DXImageList items

  1. #11

    Lock/Unlock Surfaces

    Back to what cairnswm said, I tried to experiment with the lock/unlock funtions (that's supposed to be used with pixel manipulation), but I can't Lock function work properly... any help?

    I've tried:

    [pascal]
    with DXImageList.Items[0].PatternSurfaces[0] do begin

    Lock(ClientRect,SurfaceDesc);

    end;
    [/pascal]


    The following error occurs:

    "Constant object cannot be passed as var paremeter"

    Hope anybody can help.

    Regards,
    Floken

  2. #12

    Save modified DXImageList items

    Just call the function

    DXImageList1.Items.Restore

    when you are done with the editing and it should work.
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  3. #13

    Save modified DXImageList items

    I've tried it before, didn't work...

    ...I'll apreciate if someone could make the example I've posted working.

    Thanx in advance !!

    Regards,
    Floken

  4. #14

    Save modified DXImageList items

    Actually it does work, and i have tested it.


    [pascal]

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    {
    DXImageList1.Items.Add;

    DXImageList1.Items[0].Name:='Base';
    DXImageList1.Items[0].Picture.Bitmap.LoadFromFile('Base.bmp');
    DXImageList1.Items[0].Restore;


    DXImageList1.Items.SaveToFile('gfx.dxg');
    }

    DXImageList1.Items.LoadFromFile('gfx.dxg');
    end;
    [/pascal]
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  5. #15

    Save modified DXImageList items

    Yes I can load from file and save to it without problems... but if I draw something into the ImageList.Item's surface, and then save the whole ImageList to a file, the drawings made to that surface don't get saved.

    The strange(?) fact is the changes seems to be really made, for example, if I draw something to ImageList.Item[0].PatternSurfaces[0] , then "jump" to ImageList.Item[1].PatternSurfaces[0], and then back to ImageList.Item[0].PatternSurfaces[0], the "drawings" I made are available (I make that surface visible by drawing it to DDraw1.Surface then DDraw1.Flip).

    here is some code from the example (added the "restore" line) you can download from my site:



    [pascal]

    // --- MouseMove --------------------------------------------------------------
    procedure TForm1.DXDrawMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    begin

    // if left button pressed
    if ssLeft in Shift then begin

    // draw something into DXImageList2
    DXImageList1.Items[0].DrawAlpha(DXImageList2.Items[0].PatternSurfaces[0],Bounds(x,y,2,2),0,12;
    DXImageList2.Items[0].PatternSurfaces[0].Restore;

    // copy it to DXDraw surface so we can see it
    DXImageList2.Items[0].Draw(DXDraw.Surface,0,0,0);
    DXDraw.Flip;

    end;
    end;

    [/pascal]

    If I try to save DXImageList2.Items to file later, all "drawings" don't get saved.

    Please download the example at www.floken.com/tmp/Example.zip

    Thanx a lot for trying to help me !!

    Best Regards,
    Floken

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •