In order to get "native" QR code support for ReportPro.NET 2.x I would like to do the following:
Provide a delegate which holds a container variable as a param whereas the container has properties for an expression as well as a System.Drawing.Bitmap
At runtime the delegate should be called with the container param with the evaluated expression value.
In my application a QR component creates a System.Drawing.Bitmap holding the expression value.
Back in ReportPro rpPicture resp. rpImage will take this Bitmap and use its content to draw the image on the Report.
Currently I'm still trying to get rpImage and the underlying CAPaint DIB functions to work with System.Drawing.Bitmap.
I already tried this (Sample code from within rpImage.LoadFromFile), unfortunately without success:
BEGIN USING VAR ms := System.IO.MemoryStream{}
BEGIN USING VAR oBmp := System.Drawing.Bitmap{cFile}
oBmp:Save(ms, System.Drawing.Imaging.ImageFormat.Png)
RETURN SELF:LoadFromDynaString(Convert.ToBase64String(ms:GetBuffer()))
END USING
END USING
SELF:Destroy()
nLen := sLen(cString) // = 62908
IF (pBuffer := StringAlloc(cString))==NULL_PTR
ThrowOutOfMemoryError()
ENDIF
SELF:pBMP := DIBCreateFromPtr(pBuffer, LONG(nLen))
IF SELF:pBMP = NULL_PTR
// SELF:pBMP is a NULL_PTR but the CAPaint-Functions do not reveal why
LOCAL nError AS INT
LOCAL pMsg AS PSZ
nError := CAPaintLastError()
pMsg := CAPaintLastErrorMsg()
RpExDebug.DebOut("Error in rpImage.LoadFromDynaString # " + nError:ToString() + ", " + Psz2String(pMsg))
ENDIF
DIBConvertTo24Bits(SELF:pBmp)
MemFree(pBuffer)
RETURN SELF:IsValid
Due to the SELF:pBmp = NULL_PTR the image itself does not appear on the report. I don't know whether it could be an Unicode - Ansi thing when converting the bitmap content from the memory stream to a string value.
Hi Bernhard,
PMFJI: IMHO that cannot work.
You cannot code a byte array with base64 and expect to have it work correctly.
StringAlloc() should not do any conversion to/from unicode, so it may be the best to convert the byte[] to a string with Convert.ToString( ms.GetBuffer() )
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
so far it was only a test whether rpImage can work with System.Drawing.Bitmap images, too. The next step will be to provide a delegate which is supposed to be calling the method responsible for the creation of QR images by passing a macro compiled string expression as QR content including the neccessary UI settings within the Report designer.
The goal is to provide ReportPro with the ability to create QR codes with custom defined content without having to create physical image files and without having the actual QR code functionality in ReportPro as there a plenty of QR components all over the virtual world (e.g. some of our localized QR codes include images within their QR code images to prove their origin).