I'm trying to get a downloaded image to load in a native local windows form without any additional web components.
I confirmed it downloads to my local tmp folder. Usually named something like swm.0, swm.1, etc. It is a PNG image.
Attempts to read the bitmap into a field or directly into the #ImageChart component are failing because the bitmap read is failing.
I'm not sure if it is expecting the path to be on the iSeries or something.
I commented out various things I've tried. Any idea what I'm doing wrong with the Bitmap loading from file?
SUBROUTINE name(REQUEST_CHART)
#LabelDebug.Caption := "Requesting chart for data."
#ImageRefresh.Visible := false
#ImageChart.Visible := true
#Request.DoGet( #W_CHART_URL )
IF (#Request.Response.IsSuccessfulRequest.isFalse) /* Request Failure */
#LabelDebug.Caption := "Failed with status code: " + #Request.Response.HttpStatusCode.AsString
#ImageChart.Visible := false
#ImageRefresh.Visible := true
RETURN
ENDIF
#STD_BLOB := #Request.Response.AsFile /* Stores to file in TMP folder */
#STD_STRNG := #STD_BLOB.FileName /* The Path to Where it was Stored */
* #W_CHART_BLOB := #STD_BLOB
* #ImageChart.FileName := #STD_STRNG
* #ImageChart.Image <= #SYS_APPLN.CreateBitmap( #STD_STRNG )
* #ImageChart.Image.FileName := #STD_BLOB.FileName
* #ImageChart.Image.StandardImage := #SYS_APPLN.CreateBitmap( #STD_STRNG )
* #Binary.FromFile Path(#STD_STRNG)
* #ImageChart.Image <= #SYS_APPLN.CreateBitmap( #STD_STRNG )
* #LabelDebug.Caption := #STD_STRNG + " W: " + #ImageChart.Image.Width.AsString + ", H: " + #ImageChart.Image.Height.AsString
* #ImageChart.UpdateDisplay
#Bitmap <= #Sys_Appln.CreateBitmap( #STD_BLOB )
#LabelDebug.Caption := #STD_STRNG + " W: " + #Bitmap.Width.AsString + ", H: " + #Bitmap.Height.AsString
ENDROUTINE
Using a Downloaded PNG in a Form Image Component
Re: Using a Downloaded PNG in a Form Image Component
In regular Non-LANSA windows forms you have PictureBox and you can load an image from a URL using
pictureBox.Load(url)
In the LANSA RDML the Load function doesn't seem to be pulled though so
#ImageChart.Load( #W_CHART_URL )
Gives the "Feature name Load is not a member of component type PRIM_IMAG"
So that's why I'm downloading the image locally through XPRIM_HttpRequest (which works).
pictureBox.Load(url)
In the LANSA RDML the Load function doesn't seem to be pulled though so
#ImageChart.Load( #W_CHART_URL )
Gives the "Feature name Load is not a member of component type PRIM_IMAG"
So that's why I'm downloading the image locally through XPRIM_HttpRequest (which works).
Re: Using a Downloaded PNG in a Form Image Component
Try:
#Bitmap.Image <= #Sys_Appln.CreateBitmap( #STD_BLOB )
Assuming #Bitmap is defined as a #Prim_IMAG
#Bitmap.Image <= #Sys_Appln.CreateBitmap( #STD_BLOB )
Assuming #Bitmap is defined as a #Prim_IMAG
Re: Using a Downloaded PNG in a Form Image Component
Just note a small comment in the guide:
https://docs.lansa.com/15/en/lansa016/c ... M_IMAG.htm
The PRIM_IMAG control will be used by default when dragging and dropping an image control from the Controls view in the IDE, unless the target render type is Win32.
NOTE: If your application is to execute SOLELY in Win32, you should use the image control: PRIM_IMGE.
Win32 refers to Windows in this case. So this code will work in a form/reusable part for windows:
to have this result:
https://docs.lansa.com/15/en/lansa016/c ... M_IMAG.htm
The PRIM_IMAG control will be used by default when dragging and dropping an image control from the Controls view in the IDE, unless the target render type is Win32.
NOTE: If your application is to execute SOLELY in Win32, you should use the image control: PRIM_IMGE.
Win32 refers to Windows in this case. So this code will work in a form/reusable part for windows:
Code: Select all
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) ClientWidth(600) ClientHeight(600) ComponentVersion(2) Left(406) Top(176)
Define_Com Class(#Prim_Imge) Name(#ImageWin32) Parent(#COM_OWNER) DisplayPosition(1) TabPosition(1) Height(501) Left(6) Top(6) Width(609)
Evtroutine Handling(#com_owner.CreateInstance)
Fetch Fields(#xEmployeeImage) From_File(xEmployeeImages)
* or use a blob to take a file from disk... #xEmployeeImage := 'c:\temp\lansa1.jpg'
#ImageWin32.FileName := #xEmployeeImage
Endroutine
End_Com