Transparent Cursor Badge

Transparent Cursor Badge

Amremad
Collaborator Collaborator
1,167 Views
6 Replies
Message 1 of 7

Transparent Cursor Badge

Amremad
Collaborator
Collaborator

Hi all 

 

i created a new Cursor Badge using with file named icons8-broom-40.png but when i load my function it appears like this 

Untitled.jpg

 

its mirrored and have a black background color which the png file is transparent 

 

so where is the problem cause i can solve it 

 

my code that iam using it 

 

public static PromptSelectionResult SelectionSet(string blockName,string message, KeywordCollection keys,bool icon = false)
        {
            // start select blocks which we want to edit it
            // create selection filter with typedvalues
            TypedValue[] TypedValues = new TypedValue[1];
            TypedValues.SetValue(new TypedValue((int)DxfCode.BlockName, blockName), 0);

            SelectionFilter AcSelFtr = new SelectionFilter(TypedValues);

            // create keywords options for selection
            PromptSelectionOptions AcSelOption = new PromptSelectionOptions();
            if (keys != null) foreach (Keyword key in keys) AcSelOption.Keywords.Add(key.GlobalName);

            string kws = AcSelOption.Keywords.GetDisplayString(true);

            FStarting:
            AcSelOption.MessageForAdding = (message + kws);
            string input = null;
            AcSelOption.KeywordInput +=
              delegate (object sender, SelectionTextInputEventArgs e)
              {
                  OnKeywordSelected(keys, e.Input);
                  input = e.Input;
              };
            if (input != null) goto FStarting;

            ImageBGRA32 _img = null;
            var cbu = new CursorBadgeUtilities();
            if (icon == true)
            {
                // use this lines with autocad 2015 or higher              
                var bmp = new Bitmap(AMRObjectARX.Properties.Resources.icons8_broom_40);
                _img = Utils.ConvertBitmapToAcGiImageBGRA32(bmp);              
                cbu.AddSupplementalCursorImage(_img,10);
            }

            //start selectionset with keywords and filter
            PromptSelectionResult AcSelResult =  Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(AcSelOption, AcSelFtr);

            //// use this lines with autocad 2015 or higher
            if (cbu.HasSupplementalCursorImage() && _img != null) cbu.RemoveSupplementalCursorImage(_img);

            return AcSelResult;
        }

i hope to fix it

0 Likes
Accepted solutions (1)
1,168 Views
6 Replies
Replies (6)
Message 2 of 7

ActivistInvestor
Mentor
Mentor

Have you tried using Utils.ConvertBitmapToAcGiImageBGRA32Ex() ?

 


@Amremadwrote:

Hi all 

 

i created a new Cursor Badge using with file named icons8-broom-40.png but when i load my function it appears like this 

 

i hope to fix it


 

0 Likes
Message 3 of 7

Amremad
Collaborator
Collaborator

sorry it's doesn't work 😞 

0 Likes
Message 4 of 7

ActivistInvestor
Mentor
Mentor
Accepted solution

Save the file as a Windows .BMP file with the background color set to RGB 255,0,255.

 

Then add that bitmap file to your project's resources as a System.Drawing.Bitmap resource. When your class that uses the resource is initialized, load the bitmap resource and pass it to ConvertBitmapToAcGiImageBGRA32(), and assign the result to an ImageBGRA32, and use that.

 

If the image is still mirrored, then just mirror the original source bitmap image before you save it.

 


@Amremadwrote:

sorry it's doesn't work 😞 


 

 

0 Likes
Message 5 of 7

Amremad
Collaborator
Collaborator

yes it's work now

, the background color must be magenta  but why?

still appear littler border around courser image why?

 

0 Likes
Message 6 of 7

ActivistInvestor
Mentor
Mentor

In order to support bitmap images, a color must be dedicated to indicating transparent pixels.

 

I suppose magenta is the least-likely basic color that would be used as the display background color.

 


@Amremadwrote:

yes it's work now

, the background color must be magenta  but why?

still appear littler border around courser image why?

 


 

0 Likes
Message 7 of 7

ActivistInvestor
Mentor
Mentor

@Amremadwrote:

 

still appear littler border around courser image why?

 


Not sure why that is, but I've used it with a 16x16 bitmap with 32-bit color depth, and there's no border.

 

 

0 Likes