Using a Downloaded PNG in a Form Image Component
Posted: Sat Dec 10, 2022 8:06 am
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
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