Results 1 to 8 of 8

Thread: No images in 3.20?

  1. #1
    Join Date
    Jan 2009
    Posts
    103
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default No images in 3.20?

    Hey, im having problems with my forms in Scar3.20. It wont show any images in forms. Here is the script:

    SCAR Code:
    program New;
    var
      frmDesign : TForm;
      Image1 : TImage;
      Label0 : TLabel;
      Label1 : TLabel;
      Label2 : TLabel;
      Label3 : TLabel;
      Label4 : TLabel;
      Label5 : TLabel;
      Label6 : TLabel;
      Edit0 : TEdit;
      Edit1 : TEdit;
      Edit2 : TEdit;
      ComboBox0 : TComboBox;
      ComboBox1 : TComboBox;
      ComboBox2 : TComboBox;
      Button0 : TButton;
      Button1 : TButton;
      Button2 : TButton;
      ListBox1 : TListBox;
      Button3 : TButton;
      Button4 : TButton;
      Button5 : TButton;

    procedure initform;
    begin
    frmDesign := CreateForm;
    frmDesign.Left := 250;
    frmDesign.Top := 114;
    frmDesign.Width := 463;
    frmDesign.Height := 456;
    frmDesign.Caption := 'SuperBatman'#39's Super Chinner V1.0';
    frmDesign.Color := clBtnFace;
    frmDesign.Font.Color := clWindowText;
    frmDesign.Font.Height := -11;
    frmDesign.Font.Name := 'MS Sans Serif';
    frmDesign.Font.Style := [];
    frmDesign.Visible := False;
    frmDesign.PixelsPerInch := 96;
    Image1 := TImage.Create(frmDesign);
    Image1.Parent := frmDesign;
    Image1.Left := 0;
    Image1.Top := 0;
    Image1.Width := 457;
    Image1.Height := 145;
    Label0 := TLabel.Create(frmDesign);
    Label0.Parent := frmDesign;
    Label0.Left := 24;
    Label0.Top := 176;
    Label0.Width := 51;
    Label0.Height := 13;
    Label0.Caption := 'Username:';
    Label1 := TLabel.Create(frmDesign);
    Label1.Parent := frmDesign;
    Label1.Left := 24;
    Label1.Top := 208;
    Label1.Width := 49;
    Label1.Height := 13;
    Label1.Caption := 'Password:';
    Label2 := TLabel.Create(frmDesign);
    Label2.Parent := frmDesign;
    Label2.Left := 24;
    Label2.Top := 240;
    Label2.Width := 28;
    Label2.Height := 13;
    Label2.Caption := 'Nick: ';
    Label3 := TLabel.Create(frmDesign);
    Label3.Parent := frmDesign;
    Label3.Left := 24;
    Label3.Top := 272;
    Label3.Width := 33;
    Label3.Height := 13;
    Label3.Caption := 'Active:';
    Label4 := TLabel.Create(frmDesign);
    Label4.Parent := frmDesign;
    Label4.Left := 24;
    Label4.Top := 304;
    Label4.Width := 51;
    Label4.Height := 13;
    Label4.Caption := 'Chin Color:';
    Label5 := TLabel.Create(frmDesign);
    Label5.Parent := frmDesign;
    Label5.Left := 24;
    Label5.Top := 336;
    Label5.Width := 30;
    Label5.Height := 13;
    Label5.Caption := 'Traps:';
    Label6 := TLabel.Create(frmDesign);
    Label6.Parent := frmDesign;
    Label6.Left := 248;
    Label6.Top := 176;
    Label6.Width := 129;
    Label6.Height := 13;
    Label6.Caption := 'You currently have Players:';
    Edit0 := TEdit.Create(frmDesign);
    Edit0.Parent := frmDesign;
    Edit0.Left := 80;
    Edit0.Top := 176;
    Edit0.Width := 121;
    Edit0.Height := 21;
    Edit0.TabOrder := 8;
    Edit1 := TEdit.Create(frmDesign);
    Edit1.Parent := frmDesign;
    Edit1.Left := 80;
    Edit1.Top := 208;
    Edit1.Width := 121;
    Edit1.Height := 21;
    Edit1.TabOrder := 9;
    Edit2 := TEdit.Create(frmDesign);
    Edit2.Parent := frmDesign;
    Edit2.Left := 80;
    Edit2.Top := 240;
    Edit2.Width := 121;
    Edit2.Height := 21;
    Edit2.TabOrder := 10;
    ComboBox0 := TComboBox.Create(frmDesign);
    ComboBox0.Parent := frmDesign;
    ComboBox0.Left := 80;
    ComboBox0.Top := 272;
    ComboBox0.Width := 121;
    ComboBox0.Height := 21;
    ComboBox0.ItemHeight := 13;
    ComboBox0.TabOrder := 11;
    ComboBox0.Text := 'True';
    ComboBox0.Items.Add('true');
    ComboBox0.Items.Add('false');
    ComboBox1 := TComboBox.Create(frmDesign);
    ComboBox1.Parent := frmDesign;
    ComboBox1.Left := 80;
    ComboBox1.Top := 304;
    ComboBox1.Width := 121;
    ComboBox1.Height := 21;
    ComboBox1.ItemHeight := 13;
    ComboBox1.TabOrder := 12;
    ComboBox1.Text := 'Red';
    ComboBox1.Items.Add('Red');
    ComboBox1.Items.Add('Grey');
    ComboBox2 := TComboBox.Create(frmDesign);
    ComboBox2.Parent := frmDesign;
    ComboBox2.Left := 80;
    ComboBox2.Top := 336;
    ComboBox2.Width := 121;
    ComboBox2.Height := 21;
    ComboBox2.ItemHeight := 13;
    ComboBox2.TabOrder := 13;
    ComboBox2.Text := '3';
    ComboBox2.Items.Add('3');
    ComboBox2.Items.Add('4');
    ComboBox2.Items.Add('5');
    Button0 := TButton.Create(frmDesign);
    Button0.Parent := frmDesign;
    Button0.Left := 224;
    Button0.Top := 312;
    Button0.Width := 75;
    Button0.Height := 25;
    Button0.Caption := 'Add Player';
    Button0.TabOrder := 14;
    Button1 := TButton.Create(frmDesign);
    Button1.Parent := frmDesign;
    Button1.Left := 328;
    Button1.Top := 312;
    Button1.Width := 75;
    Button1.Height := 25;
    Button1.Caption := 'New Players';
    Button1.TabOrder := 15;
    Button2 := TButton.Create(frmDesign);
    Button2.Parent := frmDesign;
    Button2.Left := 280;
    Button2.Top := 344;
    Button2.Width := 75;
    Button2.Height := 25;
    Button2.Caption := 'Save Players';
    Button2.TabOrder := 16;
    ListBox1 := TListBox.Create(frmDesign);
    ListBox1.Parent := frmDesign;
    ListBox1.Left := 256;
    ListBox1.Top := 200;
    ListBox1.Width := 121;
    ListBox1.Height := 97;
    ListBox1.ItemHeight := 13;
    ListBox1.TabOrder := 17;
    Button3 := TButton.Create(frmDesign);
    Button3.Parent := frmDesign;
    Button3.Left := 48;
    Button3.Top := 384;
    Button3.Width := 145;
    Button3.Height := 25;
    Button3.Caption := 'Edit Trap Tiles';
    Button3.TabOrder := 18;
    Button4 := TButton.Create(frmDesign);
    Button4.Parent := frmDesign;
    Button4.Left := 224;
    Button4.Top := 384;
    Button4.Width := 75;
    Button4.Height := 25;
    Button4.Caption := 'Start';
    Button4.TabOrder := 19;
    Button5 := TButton.Create(frmDesign);
    Button5.Parent := frmDesign;
    Button5.Left := 328;
    Button5.Top := 384;
    Button5.Width := 75;
    Button5.Height := 25;
    Button5.Caption := 'Exit';
    Button5.TabOrder := 20;
    end;

    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;

    procedure ShowFormModal;
    begin
      frmDesign.ShowModal;
    end;

    procedure SafeShowFormModal;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('ShowFormModal', v);
    end;

    Procedure OpenForm;
    begin
         SafeInitForm;
         SafeShowFormModal;
    end;


    begin
    Openform;
    end.

    I looked at the image part and noticed:

    Code:
    Image1 := TImage.Create(frmDesign);
    Image1.Parent := frmDesign;
    Image1.Left := 0;
    Image1.Top := 0;
    Image1.Width := 457;
    Image1.Height := 145;
    It looks like all its doing is making a box. I would put in the actual image part manually if i knew what to call, but i dont.

    Any suggestions/know what to call in the imag1 part?

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You don't even try to put anything on the image. When you place it on the form you should not try to use the thing in form editor to set the image.

    Try one of my functions
    SCAR Code:
    procedure DrawImage(var Image : TImage; bmp : integer);
    var
      width, heighth : integer;
    begin
      GetBitmapSize(bmp, width, heighth);
      CopyCanvas(getbitmapcanvas(bmp), Image.Canvas, 0, 0, width, heighth, 0, 0, width, heighth);
    end;

    You must have a bitmap declared or you can use Loadbitmap to load it from computer and return a bitmap. But the image must be on the persons hard drive to show the bitmap.

    You use it like this:
    SCAR Code:
    DrawImage(Image1, YourBitmapVarHere);

    Here it is tested:
    SCAR Code:
    program New;

    var

      frmDesign : TForm;
      Image1 : TImage;
      google : integer;

    procedure DrawImage(var Image : TImage; bmp : integer);
    var
      width, heighth : integer;
    begin
      GetBitmapSize(bmp, width, heighth);
      CopyCanvas(getbitmapcanvas(bmp), Image.Canvas, 0, 0, width, heighth, 0, 0, width, heighth);
    end;

    procedure InitForm;
    begin
      frmDesign := CreateForm;
      frmDesign.Left := 250;
      frmDesign.Top := 114;
      frmDesign.BorderStyle := bsToolWindow;
      frmDesign.Caption := 'Image Test';
      frmDesign.ClientHeight := 170;
      frmDesign.ClientWidth := 283;
      frmDesign.Color := clBtnFace;
      frmDesign.Font.Color := clWindowText;
      frmDesign.Font.Height := -11;
      frmDesign.Font.Name := 'MS Sans Serif';
      frmDesign.Font.Style := [];
      frmDesign.Position := poDesktopCenter;
      frmDesign.Visible := False;
      frmDesign.PixelsPerInch := 96;
      Image1 := TImage.Create(frmDesign);
      Image1.Parent := frmDesign;
      Image1.Left := 5;
      Image1.Top := 5;
      Image1.Width := 16;
      Image1.Height := 16;
      google := BitmapFromString(16, 16, 'beNqNkjFKA1EQhk9hodhJJJ' +
           'UHsLRN7QmCRxBSWHgR8QK2imn0ANpYrI0QsFhEQURj5G3YN+M3+yc' +
           'PUQIuw2N25p+Zf36mt7Z1MNm/HBTbG6/0ZeDn9uLu9vllXn+YJ/Pn' +
           'eX58SvjT98yvz8ybBKDqRf/UYcjevdrxyWR4dLG5ey3rD8dEbh/ep' +
           'lFTC2+W+AU8GN2DUWc+poDc2Dld3z5kEBULfEeDPqTA8NvazLMFk9' +
           'YpV38oFT4CE8dnHU3vMB7WRhD7iYcJKLhF8ybWwdiRLJHQZNmfOHt' +
           'hBMGXnmHMyfYXzwteopGNfRunFostskWrpT5kUQb+IUK2eD3ISB90' +
           'w3AKf/bSvrz4koXOV1VmKeK8pJgrvKRWCkzqxIeYVqA5+p+d3xQ+F' +
           'OKjM3hNoZwgs3Do8Auvm9HZcAyqKieBESTF0AUfZPfaV3xaJxTu7q' +
           'Ec6n+s+gZCLTmc');
      DrawImage(Image1, google);
    end;

    procedure SafeInitForm;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      ThreadSafeCall('InitForm', v);
    end;

    function ShowFormModal: Boolean;
    begin
      frmDesign.ShowModal;
    end;

    function SafeShowFormModal: Boolean;
    var
      v: TVariantArray;
    begin
      setarraylength(V, 0);
      result:= ThreadSafeCall('ShowFormModal', v);
    end;

    begin
      SafeInitForm;
      SafeShowFormModal;
      FreeForm(frmDesign);
    end.

    You don't need my function but you can copy the stuff in the function to below the declaration of the image. You don't need to credit I don't care lol.
    Last edited by Da 0wner; 04-29-2009 at 08:00 AM.

  3. #3
    Join Date
    Jan 2009
    Posts
    103
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well it worked, but it added 3000 lines to my script.. i think i saw masterkill do it similar, but not quite the same, not with the bitmap from string part, ima goo look that up.

    I shorted up that 3000 lines to 3 by looking through and using part of masterkill's program. The only downside is that now if i want to make it public, the script will have to download An include file.
    Code:
    bmp := loadbitmap(AppPath + 'SuperBatmans_Includes\Banner1.bmp');
    getbitmapsize(bmp, width, height);
    copycanvas(getbitmapcanvas(bmp), Image1.canvas, 0, 0, width, height, 0, 0, width, height);
    Last edited by superbatman; 04-29-2009 at 09:13 AM.

  4. #4
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    As I said, by using loadbitmap . You don't need an include file. You can also use my image downloader function.

    Edit:
    SCAR Code:
    {*******************************************************************************
    function DownloadImage(URL, Path : string; Overwrite : boolean) : boolean;
    By: Da 0wner
    Description: Downloads an image to the specified path.
    *******************************************************************************}


    function DownloadImage(URL, Path : string; Overwrite : boolean) : boolean;
    var
      FileNum, i : integer;
      Types : TStringArray;
    begin
      Types := ['.png', '.bmp', '.gif', '.jpg', '.jpeg', '.jng', '.mng', '.pcx'];
      URL := lowercase(URL);
      Path := lowercase(Path);
      for i := 0 to high(Types) do
      begin
        if ((EndsWith(Types[i], URL)) and (EndsWith(Types[i], Path))) then
        begin
          if ((not FileExists(Path)) or (Overwrite)) then
          begin
            if GetPage(URL) = '' then exit;
            FileNum := RewriteFile(Path, true);
            WriteFileString(FileNum, GetPage(URL));
            CloseFile(FileNum);
            if FileExists(Path) then result := true;
            exit;
          end;
        end;
      end;
    end;
    Last edited by Da 0wner; 04-29-2009 at 09:17 AM.

  5. #5
    Join Date
    Jan 2009
    Posts
    103
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Do you think i should go with the extra 3000 lines then?

  6. #6
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    no just upload the bitmap to a website like freehostia or something then have it downloaded to a certain area on startup (if the file doesnt excist) then call on it through the include, simple as that.
    “Ignorance, the root and the stem of every evil.”

  7. #7
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    1. Upload to Freehostia, or I can host it on my site if you'd like (da0wner.info).
    2. Make it download to AppPath + 'superbatman\Images\YourImage.bmp' (or w/e).
    3. Use LoadBitmap(AppPath + 'superbatman\Images\YourImage.bmp') or w/e.
    4. Draw to form.

  8. #8
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Or put the Bitmap in another .scar file and include it like SRL
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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