This is a migrated thread and some comments may be shown as answers.

Image property return nothing ?

4 Answers 9 Views
PictureBox
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 2
Veteran
Marco asked on 25 Feb 2021, 04:35 PM

I haven't found in the documentation how we can I acces the current image in a PictureBox control to save it in a database as a binary field.

If I try to access the image property, after pasting an image, it just return nothing (databinding on image property ?).

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Feb 2021, 05:36 AM

Hello, Marco,

To load an image in the RadPictureBox control or get the currently loaded one, you can use SvgImage or Image property. RadPictureBox allows editing by using a PictureBoxImageEditorDialog that internally hosts RadImageEditor. The ImageEdited occurs when the image has been edited and the user has accepted the changes. Note that this event will be fired always when the user clicks the OK button of the dialog, even if there are no changes in the image. Then, getting the Image property will give you the new modified image.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Marco
Top achievements
Rank 2
Veteran
answered on 11 Mar 2021, 05:54 PM

Hello Dess,

Sorry for the late answer.

It looks like the image property was returning nothing, despite something was drawn in the control after pasting, because I had tried to involve some Databinding on the image property. Setting and reading the image "on hand" from my DataObject is working fine.

By the way, how could we handle transparency with this control. It seems to get black when I paste transparency pictures ?

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Mar 2021, 08:49 AM

Hello, Marco,

I have tried pasting an image to RadPictureBox and after this operation is done, the Image property returns the displayed image on my end. 

As to the question at hand, when the paste operation is being processed in RadPictureBox, the Clipboard.GetImage method is internally used. That is why the transparency is lost. 

I have logged it in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to replace the default Paste menu item Click action: 

        public RadForm1()
        {
            InitializeComponent(); 

            this.radPictureBox1.ContextMenuItemClick += RadPictureBox1_ContextMenuItemClick;
        }

        private void RadPictureBox1_ContextMenuItemClick(object sender, HandledEventArgs e)
        {
            if (sender == this.radPictureBox1.ContextMenuProperties.PasteItem)
            {
                e.Handled = true;
                // Image extractedImage = // get image with transparency; 
                // this.radPictureBox1.Image = extractedImage;
            }
        }

I have researched in general programming forums for a sample approach to get the image with transparency: https://stackoverflow.com/questions/65603159/check-if-clipboard-getimage-is-transparent-in-c-sharp 

You can give it a try and apply the result image in the ContextMenuItemClick event handler.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Marco
Top achievements
Rank 2
Veteran
answered on 18 Mar 2021, 06:54 PM

Hello Dess,

I have overload the paste command to use a clipboard function supporting the alpha channel and it works perfectly.

Thanks for creating a feedback item about this, I have added my vote on it.

Best regards

Tags
PictureBox
Asked by
Marco
Top achievements
Rank 2
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Marco
Top achievements
Rank 2
Veteran
Share this question
or