1. José Gasparini
  2. PowerBuilder
  3. Thursday, 9 January 2020 14:28 PM UTC

Hi, I want to display a blob column in my window, I create a InkPicture object, get the blob column value in a blob variable, them use InkPicture.LoadInk() function, but not display the image

blob blb_imagen

 SelectBlob  foto
   Into :blb_imagen
   From admin.empleados
   Where empleado = 1
   using sqlca ;
 
If len(blb_imagen) > 0 Then
   ip_imagen.LoadInk(blb_imagen)
End If
 
Someone know why not show the image? Or If another way I can display a blob in my app mobile ?
 
Tks.
 
José

 

 

Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 9 January 2020 14:35 PM UTC
  2. PowerBuilder
  3. # 1

You loaded the BLOB value from the database. What kind of data was stored in that BLOB field? 

BLOB being just a chunk of memory I guess it may be ill-formatted for the InkPicture image.

/Michael

Comment
  1. David Peace (Powersoft)
  2. Thursday, 9 January 2020 16:54 PM UTC
Can you write the blob data to a file with extention of .jpg and view that file as the image you want?

If so you should be able to display that in the ways Michael has suggested.
  1. Helpful
There are no comments made yet.
José Gasparini Accepted Answer Pending Moderation
  1. Thursday, 9 January 2020 14:42 PM UTC
  2. PowerBuilder
  3. # 2

Hi Michael, thankyou for answer. I'm usign Sybase ASA 9, de datatype is Long Binary, I inserted an image JPG in this colum

Regards

Comment
  1. Michael Kramer
  2. Thursday, 9 January 2020 15:13 PM UTC
Two follow-up questions:

1) Can you load that JPG file directly into an InkPicture control using the IDE?

2) Can you load that JPG file dynamically using LoadPicture(<filename>)?

Not that I suggest workarounds but more to investigate the "data source" to assert it is "wellformed".

Hopefully others will join this Q&A. Honestly, I haven't used InkPicture since 2015 so I will create a tiny demo app to dust off some rust. If I remember correctly InkPicture is a little picky on picture formats for Load/Save.
  1. Helpful
  1. Michael Kramer
  2. Thursday, 9 January 2020 15:40 PM UTC
So far I have tiny app running that can load JPG from file and load JPG via BLOB. I load the BLOB from a file. Still missing save to DB and read from DB. Let me know if your JPG behaves nicely ref my prior questions (1) and (2) before I also save to DB and load again. I have a feeling your image binary data is ill-formatted.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 9 January 2020 15:43 PM UTC
  2. PowerBuilder
  3. # 3

Greetings, Jose -

Have you considered using a Picture control instead of the InkPicture control? It supports JPEG's, and you can load a blob containing the image into a Picture control via its SetPicture function.

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 9 January 2020 17:00 PM UTC
  2. PowerBuilder
  3. # 4

Hey José,

I have expanded my tiny demo app with both JPG and PNG files. Here is what I have working:

  • Load directly from file into InkPicture
  • Load via BLOB variable into InkPicture
  • Save to SQL Anywhere 17 database from file
  • Load from SQL Anywhere 17 database into InkPicture

Let me know if you want my demo-app for comparison. I will add a button to create the test table I'm using before uploading. I use really ordinary SQL in the app so it should work in older SQL Any databases - or even in other DBMS as long as you substitute the datatype for the BLOB column to whatever BLOB type that DBMS is using.

HTH /Michael

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 9 January 2020 17:07 PM UTC
  2. PowerBuilder
  3. # 5

Hi José;

  If you are using SA (formerly called ASA) and thus ODBC  ... did you set the BLOB length to go beyond 32K (its SA default)?

Regards ... Chris

 

Comment
  1. Michael Kramer
  2. Friday, 10 January 2020 09:42 AM UTC
For comparison I use datatype = "long binary" and have no problems saving/loading PNG file of 39 kB
  1. Helpful
There are no comments made yet.
José Gasparini Accepted Answer Pending Moderation
  1. Friday, 10 January 2020 17:51 PM UTC
  2. PowerBuilder
  3. # 6

Thanks for all answer, I resolved the issue, the problem was the image size, I had to control that it's low or 32K to show, and I changed InkPicture for p_1.SetPicture. 

 

Thanks very much

Comment
  1. Chris Pollach @Appeon
  2. Friday, 10 January 2020 18:22 PM UTC
Hi José;

No .. you should have increased the BLOB Data size in the PBODBCxxx.ini file. What you have now is reduced image clarity and still a chance that images approaching 32K will be truncated.

Regards ... Chris
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Friday, 10 January 2020 18:23 PM UTC
  2. PowerBuilder
  3. # 7

Hey José! You may alter the data type for "image content" to expand beyond 32 kB.

My test table supports files up to 2 GB each. Code here is for SQL Anywhere 17.

CREATE TABLE "test_file"(
   "file_ID"  integer  not null DEFAULT autoincrement,
   "filename" varchar(260) null,
   "content"  long binary  null,  /* varbinary(max) in MSSQL.   BLOB in Oracle SQL */
   primary key ("file_ID"));

HTH /Michael

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.