Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Drawing a bitmap inside a dialog

    SDK Help
    0
    33
    16.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 14/02/2005 at 04:26, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   8.100 
      Platform:   Windows  ; Mac  ;  Mac OSX  ; 
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      I'm trying to draw a bitmap (82x82 pixels) inside a user area. I created that user area with Resedit and it is named x_pic
      So, now I have by bitmap addressed by the variable bm and I want to draw it inside the x_pic user area.
      I'm doing this:

        
      user=GeUserArea(x_pic,dialog);  
      user->DrawBitmap(bm,0,0,81,81,0,0,81,81);  
      

      But its showing nothing. What am I doing wrong?
      Thank you very much in advance for any help.

      Rui Batista

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 14/02/2005 at 07:30, xxxxxxxx wrote:

        Ok, definetely, why can't this be simpler?
        I have a User Area defined with a name: xpic. Why can't I simply type:

          
        DrawBitmap(xpic,bitmap_path,0,100,0,100)  
        

        ?

        I know this command doesn't exist. But WHY, oh why can't it be as simple as this!?!?
        I ask again: how can I draw a bitmap into an user area that I defined in a dialog resorce?

        Rui Batista

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 14/02/2005 at 10:02, xxxxxxxx wrote:

          Using COFFEE, I was never able to do it. Even using C++ SDK, I use BitmapButtonCustomGUI since it works every time and is nice and expedient. Without it my interPoser plugin would not be (used for thumbnail displays, logo display, about display, convert image display).

          I did a forum search and couldn't find it, but I thought there was a similar thread with a possible COFFEE solution to this (or maybe just a realization of its non-solution). I'll let you know if I find it.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 14/02/2005 at 10:09, xxxxxxxx wrote:

            Thank you, Robert. I also performed a search but found nothing that could help me 😞
            But it should be possible. I just don't know how.

            Rui Batista

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 14/02/2005 at 10:49, xxxxxxxx wrote:

              Okay, Rui,

              Try the relevant sections of this code (modified "Async Bounce.cof"). Seems to load my "about.jpg" image. Amazing! 🙂

              (using v8.012 to keep it near version)

                
              // be sure to use a unique ID obtained from www.plugincafe.com  
              var PLUGIN_ID = 910000;  
              // be sure to use a unique ID obtained from www.plugincafe.com  
                
              // global variables  
              var col,speed;  
              var text;  
                
              // definition of my user area  
              class MyUserArea : GeUserArea  
              {  
                   private:  
                        var bbm;  
                
                   public:  
                        MyUserArea(id,dialog);  
                        Init();  
                        GetUserWidth();  
                        GetUserHeight();  
                
                        Draw(x1,y1,x2,y2);  
              }  
                
              MyUserArea::MyUserArea(id,dialog)  
              {  
                   super(id,dialog);  
              }  
                
              MyUserArea::Init()  
              {  
                   var filename = GeGetRootFilename();  
                   filename->RemoveLast();  
                   filename->AddLast("about.jpg");  
                   bbm = new(BaseBitmap, 256,256);  
                   bbm->Load(filename, 0);  
                   println(filename->GetFullString());  
                   Redraw();  
              }  
                
              MyUserArea::GetUserWidth()  
              {  
                   return 256;  
              }  
                
              MyUserArea::GetUserHeight()  
              {  
                   return 256;  
              }  
                
              MyUserArea::Draw(x1,y1,x2,y2)  
              {  
                   OffScreenOn();  
                   SetClippingRegion(x1,y1,x2,y2);  
                
                   DrawBitmap(bbm, 0, 0, 255, 255, 0, 0, 255, 255, BMP_NORMAL);  
              }  
                
              // ***********************************************  
                
              // definition of my Dialog class  
              class MyDialog : GeDialog  
              {  
                   private:  
                        var ua;  
                
                   public:  
                        MyDialog();  
                
                        CreateLayout();  
                        Init();  
                        Command(id,msg);  
              }  
                
              MyDialog::MyDialog()  
              {  
                   super(PLUGIN_ID);  
                   ua=NULL;  
              }  
                
              MyDialog::CreateLayout()  
              {  
                   SetTitle("Bitmap");  
                
                   AddUserArea(5000,BFH_SCALEFIT|BFH_SCALEFIT,0,0);  
                
                   AddGroupBeginV(4000,0,3,"Group",0);  
                   {  
                        AddStaticText (4001,BFH_FIT,0,0,"Name",0);  
                        AddEditText   (4002,BFH_FIT,0,0);  
                        AddCheckbox   (4003,BFH_FIT,0,0,"Test");  
                
                        AddStaticText (4004,BFH_FIT,0,0,"Speed",0);  
                        AddEditNumber (4005,BFH_FIT,70,0);  
                        AddStaticText (4001,BFH_FIT,0,0,"",0);  
                
                        AddStaticText (4006,BFH_FIT,0,0,"Color",0);  
                
                        AddColorField (4007,BFH_FIT,120,13);  
                   }  
                   AddGroupEnd();  
                
                
                   AddRadioGroupV(7000,0,2);  
                   AddItem(7000,6000,"Test a");  
                   AddItem(7000,6001,"aha");  
                   AddItem(7000,6002,"bha");  
                   AddItem(7000,6003,"Test n");  
                   AddItem(7000,6003,"Test n");  
                
                   ua = new(MyUserArea,5000,this);  
                
                   return TRUE;  
              }  
                
              MyDialog::Init()  
              {  
                   SetString (4002,text);  
                   SetCheckbox(4003,TRUE);  
                   SetPercent (4005,speed,0.0,100.0,1.0);  
                
                   SetColorField(4007,col);  
                
                   SetItem(7000,6002);  
              }  
                
              MyDialog::Command(id,msg)  
              {  
                   switch (id)  
                   {  
                        case 4005: speed = GetPercent(id); break;  
                        case 4007: col   = GetColor(id); break;  
                        case 4002: text = GetString(id); break;  
                   }  
              }  
                
              // ***********************************************  
                
              class MyMenuPlugin : MenuPlugin  
              {  
                   public:  
                        MyMenuPlugin();  
                
                        GetID();  
                        GetName();  
                        GetHelp();  
                        Execute(doc);  
                
                        RestoreLayout(secret,subid);  
              }  
                
              MyMenuPlugin::MyMenuPlugin()  
              {  
                   super();  
              }  
                
              MyMenuPlugin::GetID()  
              {  
                   return PLUGIN_ID;  
              }  
                
              MyMenuPlugin::GetName()  
              {  
                   return "Async Bounce";  
              }  
                
              MyMenuPlugin::GetHelp()  
              {  
                   return "Shows programming of async dialogs with timer events";  
              }  
                
              var d;  
                
              MyMenuPlugin::Execute(doc)  
              {  
                   d->Open(TRUE,-1,-1);  
              }  
                
              MyMenuPlugin::RestoreLayout(secret,subid)  
              {  
                   if (!d) d = new(MyDialog);  
                   d->RestoreLayout(secret);  
              }  
                
                
              main()  
              {  
                   d = new(MyDialog);  
                
                   col   = vector(1,0,0);  
                   speed = 50.0;  
                   text = "o";  
                
                   Register(MyMenuPlugin);  
              }  
              

              Good luck - let me know if it works for you.

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 14/02/2005 at 10:55, xxxxxxxx wrote:

                Should mention that there is a post where the code breaks in 8.5. If you have 8.5 or 9.0, try it there as well to see if it still displays the bitmap.

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 14/02/2005 at 18:02, xxxxxxxx wrote:

                  Well, the problem with it is that I don't know how to make it work with a dialog that is loaded from a resorce and where the User Areas are already defined. In your example (I had already found the "Async Bounce.cof" file) we define, manualy, our own User Area. In my example, I have three User Areas, defined with Resedit.

                  Rui Batista

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 14/02/2005 at 18:41, xxxxxxxx wrote:

                    Hi Rui,

                    all you then need to do is allocate the userarea that should be attached to your userarea fields.

                    So if you defined a UA in ResEdit with the ID "IDC_RUISAREA" for example, you need to call

                    ua = new(MyUserArea,IDC_RUISAREA,this);

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 14/02/2005 at 18:44, xxxxxxxx wrote:

                      Mmmmm, I will give it a try. What I can't understand is that is the "this" variable.

                      Rui Batista

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 14/02/2005 at 18:51, xxxxxxxx wrote:

                        Hey Rui,

                        if you look into the COFFEE docs you can see the constructor of the class:

                        GeUserArea([int] id, [GeBaseDialog] dialog);

                        id = IDC_RUISAREA
                        and
                        dialog = this

                        "this" is the pointer of the class it´s used in. (in this case a pointer to your dialog)

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 15/02/2005 at 07:16, xxxxxxxx wrote:

                          I tried to use:

                            
                          user_x=GeUserArea(X_PIC,this);  
                          

                          But I keep getting this error:

                          (7) CLASS is not a function

                          What can be wrong with it?

                          Rui Batista

                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 15/02/2005 at 08:38, xxxxxxxx wrote:

                            You have to use 'new' on a class to call the constructor in COFFEE:

                            user_x = new(GeUserArea(X_PIC,this));

                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 15/02/2005 at 08:57, xxxxxxxx wrote:

                              I still get the same error 😞

                              Rui Batista

                              1 Reply Last reply Reply Quote 0
                              • H
                                Helper
                                last edited by

                                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                On 15/02/2005 at 09:40, xxxxxxxx wrote:

                                If you are going to create the GeUserArea programatically and attach to the dialog, you may need to derive your own class and use the code as in the example. My experience with this stuff in COFFEE is limited, so I usually stick with the examples and other existing code when possible. 🙂

                                1 Reply Last reply Reply Quote 0
                                • H
                                  Helper
                                  last edited by

                                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                  On 15/02/2005 at 09:45, xxxxxxxx wrote:

                                  No, I'm not going to create a User Area programatically. I simply want to have access to user areas I already defined with Resedit in a dialog resorce. But I think this is excessivelly complicated 😞

                                  Rui Batista

                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    Helper
                                    last edited by

                                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                    On 15/02/2005 at 09:57, xxxxxxxx wrote:

                                    What´s the problem with using

                                    new(name of your userarea class,IDC_RUISAREA,this);

                                    ?

                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      Helper
                                      last edited by

                                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                      On 15/02/2005 at 10:03, xxxxxxxx wrote:

                                      Quote: Originally posted by Rui Batista on 15 February 2005
                                      >
                                      > * * *
                                      >
                                      > I simply want to have access to user areas I already defined with Resedit in a dialog resorce.
                                      >
                                      >
                                      > * * *

                                      In ResEdit you only define the UserArea gui, but that won´t create a GeUserArea instance for you. You have to derive your own class from the GeUserArea Base class to get access to it. There is no way around it afaik.

                                      1 Reply Last reply Reply Quote 0
                                      • H
                                        Helper
                                        last edited by

                                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                        On 15/02/2005 at 10:12, xxxxxxxx wrote:

                                        Oh, ok... so I still have to derive the class. Damn, its really confusing. No wonder so many people run away from programming 😉
                                        I will give it a try. Probably I will only have time tomorrow. Thank you both for the time and effort into helping me out. I will report my success/failure 😉

                                        Rui Batista

                                        1 Reply Last reply Reply Quote 0
                                        • H
                                          Helper
                                          last edited by

                                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                          On 16/02/2005 at 12:00, xxxxxxxx wrote:

                                          Ok, definetely, I can't seem to make it work. This is what I wrote:
                                          {

                                            
                                          class MyUserArea : GeUserArea  
                                          {  
                                               private:  
                                                    var bbm;  
                                            
                                               public:  
                                                    MyUserArea(id,dialog);  
                                                    Init();  
                                                    GetUserWidth();  
                                                    GetUserHeight();  
                                                    Draw_Pic(name);  
                                          }  
                                            
                                          MyUserArea::MyUserArea(id,dialog)  
                                          {  
                                               super(id,dialog);  
                                          }  
                                            
                                          MyUserArea::Init()  
                                          {var bm_path,bbm;  
                                                 
                                               bm_path=GeGetRootFilename();  
                                               bm_path->RemoveLast();       
                                               bm_path->AddLast("align_pics");  
                                               bm_path->AddLast("x01.jpg");  
                                               bbm=new(BaseBitmap,82,82);  
                                               bbm->Load(bm_path,0);  
                                               if(!bbm)  
                                               {  
                                               println("Error getting a picture.");  
                                               return;  
                                               }  
                                          }  
                                            
                                          MyUserArea::GetUserWidth()  
                                          {  
                                               return 82;  
                                          }  
                                            
                                          MyUserArea::GetUserHeight()  
                                          {  
                                               return 82;  
                                          }  
                                            
                                          MyUserArea::Draw_Pic(name)  
                                          {var bm_path,bbm;  
                                                 
                                              OffScreenOn();  
                                              SetClippingRegion(x1,y1,x2,y2);  
                                               name=stradd(name,".jpg");  
                                               bm_path=GeGetRootFilename();  
                                               bm_path->RemoveLast();       
                                               bm_path->AddLast("align_pics");  
                                               bm_path->AddLast(name);  
                                               bbm=new(BaseBitmap,82,82);  
                                               bbm->Load(bm_path,0);  
                                               if(!bbm)  
                                               {  
                                               println("Error getting a picture.");  
                                               return;  
                                               }  
                                                 
                                               DrawBitmap(bbm,0,0,81,81,0,0,81,81,BMP_NORMAL);  
                                          }  
                                            
                                          class PluginDialog : GeDialog  
                                          {  
                                          private:  
                                               var bc;  
                                               ContainerToDialog();  
                                               DialogToContainer();  
                                                 
                                          public:  
                                          PluginDialog();  
                                            
                                          CreateLayout();  
                                          Init();  
                                            
                                          GetContainer();  
                                          SetContainer(_bc);  
                                            
                                          Message(msg);  
                                          Command(id, msg);  
                                          }  
                                            
                                          PluginDialog::PluginDialog()   
                                          {   
                                               super(PLUGIN_ID);  
                                               bc = new(BaseContainer);  
                                          }  
                                            
                                          PluginDialog::GetContainer() { return bc->GetClone(); }  
                                          PluginDialog::SetContainer(_bc) { bc = _bc->GetClone(); }  
                                            
                                          PluginDialog::CreateLayout()  
                                          {  
                                               return LoadDialogResource(ALIGNER, PLUGIN_RES, 0);  
                                          }  
                                          ...  
                                          

                                          Where must I add the

                                          new(name of your userarea class,IDC_RUISAREA,this);
                                          

                                          ?

                                          Rui Batista

                                          1 Reply Last reply Reply Quote 0
                                          • H
                                            Helper
                                            last edited by

                                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                            On 16/02/2005 at 12:44, xxxxxxxx wrote:

                                            In CreateLayout().

                                            Try it like this:

                                              
                                            PluginDialog::CreateLayout()  
                                            {  
                                            var retval = LoadDialogResource(ALIGNER, PLUGIN_RES, 0);  
                                            ua = new(MyUserArea, id, this);  
                                            return reval;  
                                            }  
                                            

                                            If your user area is defined in the Dialog Resource, then you don't need to AddUserArea(). If not, you must.

                                            Don't forget to set the id to the correct value!

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post