Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
JPG's & Crystal Reports
Message
From
19/11/2006 15:01:01
 
General information
Forum:
Visual FoxPro
Category:
Crystal Reports
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
00960750
Message ID:
01171076
Views:
8
FYI....CR XI now has built-in support for dynamic images.

In CR XI, you can drop a picture/image control on the report body. Then right-click the picture and select Format Object on the shortcut menu. This will load the Format Editor. Go to the Picture tab, and then click the formula icon to the right of the Graphic Location option. This will load the Formula Editor, where you can specify a simple formula for the Graphic Location. The formula is simply the table name and column that stores the reference to the image (e.g. dtInvoiceHeader.ClientLogoName).

Prior to CR11, you could implement dynamic images by loading the image into a binary column. Now, I realize this is .NET code, not VFP code, I never had to do dynamic images from within VFP - maybe this can be done from within VFP, so here's the way I had to do it prior to CR11 in .NET, and hopefully this can be done in VFP.

First, define a new data column in the supporting DataTable [ClientLogo]. The DataType must be base64binary, which I can set in the XML Schema Editor for the typed dataset. Alternatively, I can define the data type as a byte array (System.Byte[]) in the standard DataSet Editor.

Second, after I define the binary column in the result set, I must insert the column in the report design area. Note that Crystal Reports will treat the column as a BLOB object, which I can then size and position as needed.

Finally, I need to populate the image at run time when I populate the rest of the result set contents. The sample below is the code for creating a binary reader and inserting the picture image into the dataset.
dsInvoices odsInvoices = new dsInvoices();
string cPicFileName = "c:\\MyLogo.JPG";
// Must create a stream and a reader
FileStream fsStream =
    new FileStream(cPicFileName, FileMode.Open);

BinaryReader br = new BinaryReader(fsStream);

-- create an instance of the new datarow 
dsInvoices.dtInvoicesRow oRow = 
   odsInvoices.dtInvoices.NewdtInvoiceRow();
-- Set the logo, and any other columns
oRow.ClientLogo = 
     br.ReadBytes((int)br.BaseStream.Length);
odsInvoices.dtInvoices.AdddtInvoicesRow(oRow);
Yes, it does mean your supporting datatable will be quite large if you have a high number of rows and/or large images. But prior to CR11, it's the only way I knew to handle it.


Hope that helps...
Kevin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform