Hot to bind FieldValue to a Image Control??

Stimulsoft Reports.Silverlight discussion
lowence
Posts: 8
Joined: Thu Jun 02, 2011 2:26 am

Hot to bind FieldValue to a Image Control??

Post by lowence »

I have a bussnessobject with a Image Field.

Bind the Image Field to a Image Control.

But ,it's nothing appear.

How can i do it??
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Hot to bind FieldValue to a Image Control??

Post by Andrew »

Hello,

The way you try to do is impossible. Binding Objects is not supported there.

Thank you.
lowence
Posts: 8
Joined: Thu Jun 02, 2011 2:26 am

Hot to bind FieldValue to a Image Control??

Post by lowence »

I see the Images Demo of C# Samples (ClientServer).

It show the Image Control can be bind to a byte[] type column.

But when i try use the same way,it not run fine??

Why?And is there some another way??
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Hot to bind FieldValue to a Image Control??

Post by Andrew »

Hello,

Please send us an example of your application with an example Business Objects. We will see what you're doing wrong and try to help you.

Thank you.
lowence
Posts: 8
Joined: Thu Jun 02, 2011 2:26 am

Hot to bind FieldValue to a Image Control??

Post by lowence »

TheDataSource:

public class ImageDemo
{
public string Name { get; set; }
public object Image { get; set; }


public static ImageDemo GetItems()
{
// a local image
var bitmap = new BitmapImage(new Uri("/ReportingHelper;component/Images/OnePage.png", UriKind.RelativeOrAbsolute));

// convert to base64 string
string str =GetBase64Image(bitmap); // i try use StiImageConverter.ImageToPackedString(bitmap) or StiImageConverter.ImageToString(bitmap), but the method throw a null point exception.

// return the object
return new ImageDemo() { Name = "Zhang San", Image = str };
}

}

Application Method:
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ReportingHelper.2.mrt");

StiReport report = new StiReport();
report.Load(stream);
report.CalculationMode = StiCalculationMode.Interpretation;

Type type = typeof(ImageDemo);

report.RegBusinessObject(type.Name, type.Name, ImageDemo.GetItems());

report.Render();

this.PreviewControl.Report = report;
}


The Report Mrt, I bind a DataColumn to a StiImage Control the Code snippets:


[216:216:216]
8.8,0.6,7.4,6.4
p.Page1

ImageDemo.Image
Image1


True
Anton Lozovskiy
Posts: 135
Joined: Tue Aug 11, 2009 9:38 am

Hot to bind FieldValue to a Image Control??

Post by Anton Lozovskiy »

Hello,

We create an example for you, please see.

Thank you.
Attachments
1067.SilverlightApplication1.zip
(23.96 KiB) Downloaded 544 times
yasminteles
Posts: 7
Joined: Tue Dec 04, 2012 1:37 am

Re: Hot to bind FieldValue to a Image Control??

Post by yasminteles »

Hello.

This example error occurs on the line below:

Code: Select all

string str = StiImageConverter.ImageToString(bitmap as BitmapImage);
Error: Object reference not set to an instance of an object.

I'm with Stimulsoft Reports.Silverlight version 2014.2.1905 from 05/30/2014

Att
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Hot to bind FieldValue to a Image Control??

Post by Alex K. »

Hello,

Can you please send us a sample project which reproduce the issue for analysis.

Thank you.
yasminteles
Posts: 7
Joined: Tue Dec 04, 2012 1:37 am

Re: Hot to bind FieldValue to a Image Control??

Post by yasminteles »

Hello.

My errors with images in reports: Images in project and Images in database.

The example http://websl.stimulsoft.com/?reportname=Images, the image already converted and the data source is an xml file

Code: Select all

        servicoWCF.ConsultaRelatorioAsync();

        void servicoWCF_ConsultaRelatorioCompleted(object sender, ConsultaRelatorioCompletedEventArgs e)
        {
            if (e.ncErro == null && e.Result != null)
            {
                Data dataRelatorio = new Data();
                Data.ncConteudoCollection conteudoColecao;
                Data.ConteudoItem conteudo;

                foreach (ncRelatorio1 item in e.Result)
                {
                    conteudo = new Data.ConteudoItem();
                    
                    //Name
                    conteudo.Info03 = item.Info2;   
                    //Company
                    conteudo.Info04 = item.Info3;   

                    //*********************************************************************************
                    //doubt 1 - Image is in project (Company Logo)                    
                    BitmapImage bitmapImage = new BitmapImage(new Uri("/nc.Relatorio;component/Recursos/Imagens/Logo.png", UriKind.Relative));

                   //Error when trying to convert with StiImageConverter (Error: Object reference not set to an instance of an object)
                    byte[] image = StiImageConverter.ImageToBytes(bitmapImage);    

                    //conteudo.Info49 - byte[] type in Stimulsoft Businnes Object. I am using the DataColumn property for the image component.
                    conteudo.Info49 = image;                

                    //The example http://forum.stimulsoft.com/viewtopic.php?f=11&t=4498 - 1067.SilverlightApplication1.zip also contains this error

                    //*********************************************************************************
                    
                    //doubt 2 -  Image in database is not displayed in the report, only Name and Company
                    //Commenting on the previous error 
                    //item.Info50 - byte array with person's photo
                    //conteudo.Info50 - byte[] type in Stimulsoft Businnes Object. I am using the DataColumn property for the image component.
                    conteudo.Info50 = item.Info50;                         
                    
                    //*********************************************************************************

                    dataRelatorio.Conteudo.Add(conteudo);
                }

                System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();                
                StreamReader reader = new StreamReader(a.GetManifestResourceStream("nc.Relatorio.Relatorios.NR0101.mrt"));
                StiReport report = new StiReport();
                report.Load(reader.BaseStream);
                reader.Close();
                reader.Dispose();
                report.CalculationMode = StiCalculationMode.Interpretation;
                report.RegBusinessObject("Data", "Data", dataRelatorio);

                report.Render();
                report.Show();

            }
        }

Please help me.

Thankyou

Teles
yasminteles
Posts: 7
Joined: Tue Dec 04, 2012 1:37 am

Re: Hot to bind FieldValue to a Image Control??

Post by yasminteles »

Hello.

About load image in database I resolved the problem, but I need load image in project.

Code: Select all

        servicoWCF.ConsultaRelatorioAsync();

        void servicoWCF_ConsultaRelatorioCompleted(object sender, ConsultaRelatorioCompletedEventArgs e)
        {
            if (e.ncErro == null && e.Result != null)
            {
                Data dataRelatorio = new Data();
                Data.ncConteudoCollection conteudoColecao;
                Data.ConteudoItem conteudo;

                foreach (ncRelatorio1 item in e.Result)
                {
                    conteudo = new Data.ConteudoItem();
                    
                    //Name
                    conteudo.Info03 = item.Info2;   
                    //Company
                    conteudo.Info04 = item.Info3;   

                    //*********************************************************************************
                    //doubt 1 - Image is in project (Company Logo)                    
                    BitmapImage bitmapImage = new BitmapImage(new Uri("/nc.Relatorio;component/Recursos/Imagens/Logo.png", UriKind.Relative));

                  [size=150][color=#FF0040] //Error when trying to convert with StiImageConverter (Error: Object reference not set to an instance of an object)
                    byte[] image = StiImageConverter.ImageToBytes(bitmapImage);    [/color][/size]

                    //conteudo.Info49 - byte[] type in Stimulsoft Businnes Object. I am using the DataColumn property for the image component.
                    conteudo.Info49 = image;                

                    //The example http://forum.stimulsoft.com/viewtopic.php?f=11&t=4498 - 1067.SilverlightApplication1.zip also contains this error

                    dataRelatorio.Conteudo.Add(conteudo);
                }

                System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();                
                StreamReader reader = new StreamReader(a.GetManifestResourceStream("nc.Relatorio.Relatorios.NR0101.mrt"));
                StiReport report = new StiReport();
                report.Load(reader.BaseStream);
                reader.Close();
                reader.Dispose();
                report.CalculationMode = StiCalculationMode.Interpretation;
                report.RegBusinessObject("Data", "Data", dataRelatorio);

                report.Render();
                report.Show();

            }
        }

Please, help me.

Thank's
Locked