Picture control

Posted by: vbie on 14 November 2017, 11:32 am EST

    • Post Options:
    • Link

    Posted 14 November 2017, 11:32 am EST

    Where I can some information how to work with DataField in AR picture control?

    I see the picture control has property DataField. I try to set value for it that was encoded like base64, but it doesn’t work.

    DataSourse is xml that contain picture like base64.

    Can you help me?

  • Posted 15 November 2017, 11:02 am EST

    Hello,

    You would need to convert the Base64 data to image using the code. Suppose the name of the image field in your XML data Source is “ItemImage” then you can use the code as follows to convert the image for Picture control as follows:

    
    DataSet imagesData;
    		int rowCounter;
    		private void ImageReport_DataInitialize(object sender, System.EventArgs eArgs)
    		{
    			// DataSet to hold data
    			imagesData = new DataSet();
    			
    			//your image xml data source
    			imagesData.ReadXml(Application.StartupPath + "\\Images.xml");
    
    			// initialize the counter to the first row
    			rowCounter = 0;
    
    			// Add the columsn from the dataset as field			
    			this.Fields.Add("ItemImage");
    
    		}
    		private void ImageReport_FetchData(object sender, DataDynamics.ActiveReports.ActiveReport.FetchEventArgs eArgs)
    		{
    			if ( rowCounter == imagesData.Tables[0].Columns.Count)
    			{
    				eArgs.EOF = true;
    				return;
    			}
    			else
    			{				
    				// the image field				
    				string strPhoto = (string)imagesData.Tables[0].Rows[rowCounter]["ItemImage"];
    				byte[] arPhoto = Convert.FromBase64String(strPhoto);
    				MemoryStream memStrm = new MemoryStream( arPhoto, 0, arPhoto.Length );
    				Bitmap bm = new Bitmap(memStrm);
    				this.Fields["ItemImage"].Value = bm;
    
    				// Advance Row counter
    				eArgs.EOF = false;
    				rowCounter++;
    			}
    		}
    
    
    

    I hope it help!

    Thanks,

    Deepak Sharma

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels