Resolution image

Bonjour,
j’ai un petit problème d’affichage d’image issue d’une base de données dans des canvas, je n’arrive pas à avoir une bonne netteté avec des images pourtant enregistrées en 300 de résolution.
Est-ce normal ou j’ai oublié quelque chose avant d’enregistrer en FormatPNG ?
Ma manip : je colle ma fenêtre avec un Drawinto dans ma picture précédemment déclarée avec une résolution de 300 et je l’enregistre avec “EncodeBase64(img_Globale.GetData(Picture.FormatPNG),0)”.
(img_Globale est ma picture)
Est-ce que ce que je fais est correct ?

Bonjour,
Peut-on voir le code complet ?

Le problème vient peut-être du DrawInto qui va changer la qualité de l’image.

Dim Img_Globale as new picture(Win.Width,Win.Height,32)
Img_Globale.HorizontalResolution=300
Img_Globale.VerticalResolution=300
'Stockage de la fenêtre dans l’image p
Win.DrawInto(Img_Globale.Graphics, 0, 0)
'--------------------------------
'Enregistrement
dim Res as string=EncodeBase64(img_Globale.GetData(Picture.FormatPNG),0)
Dim row As new DatabaseRecord
row.Column(Picture_Win_Globale)=Res
'Enregistrement
App.mDB.InsertRecord(Pictures_Diff_t,row)

Question : comment faut-il déclarer le champs (ici) “Picture_win_Globale” dans la DB.
Je l’ai mis en TEXT.

Hello!

If your database is a SQLite database, I would declare the data field for an image as a BLOB.

Example:

sql = "create table Netzhaut(Kundennummer integer, Zeitstempel string, BildTyp integer, "+ _
"NetzhautRechts blob, NetzhautLinks blob, LfdNr integer, fSub string, "+ _
"primary key (Kundennummer, Zeitstempel, BildTyp))"

The pictures are in “NetzhautRechts” and “NetzhautLinks”.

When I write an image to a database, I write the MemoryBlock to the database:

dbRow.Column("NetzhautRechts").BlobValue = PufferNetzhaut.NetzhautTyp2Rechts

DB.AddRow(DB_Table_Netzhaut,dbRow)

If I read the image from the database, it looks like this:

PufferNetzhaut.NetzhautTyp1Rechts = row.Column("NetzhautRechts").BlobValue

Where the buffer “PufferNetzhaut.NetzhautTyp1Rechts” is a memory block.

j’ai fait un essai avec extension “Blob”, pas de changement. Je pense que ma version de Xojo est trop ancienne (2016). Quand je récupère mon enregistrement je n’ai pas l’extension ‘BlobValue’.
Je vais devoir opter pour une version plus récente.
Je suis allé sur le site ‘XOJO’, il n’accepte pas le paiement par ApplePay. C’est bizarre ?
Est-ce qu’une version LITE (99$) est suffisante ?
On paye pour 1 année seulement ?

First of all, sorry for the English answer - unfortunately I can’t do this in French.

My example was from a program written with API2.
Of course you can also create a BLOB with API1. I think it should then look like this:

dbRec = new DatabaseRecord
dbRec.BlobColumn("MyBlobColumn")  = MyMemoryBlock
db.InsertRecord("MyTable",dbRec)

Maybe like this

dbRec.BlobColumn("MyBlobColumn") = MyPicture.GetData(Picture.FormatPNG)

I save images in the original resolution, first in a MemoryBlock and then in the database in a BLOB.
When I display such an image, I place the MemoryBlock (the original image) in a Picture:

MyPicture = Picture.FromData(MyMemoryBlock)

The picture is transferred to the canvas with

g.DrawPicture MyPicture, 0, 0, g.Width, g.Height, 0, 0, MyPicture.Width, MyPicture.Height

in the PAINT event of the canvas.

Unfortunately, I have never changed or used the resolution. I can’t help there.

But when I display images, they can have different formats. In my case, this is 4:3, 4:4 or 4:5.
I then change the aspect ratio of the canvas at runtime (in my case 4:3 = 1024x768 or 2048x1536, 4:4 = 1024x1024, 4:5 288x352). This is my individual solution. This way I don’t get any distortions. The sharpness in XOJO corresponds to the sharpness of the image.

Is your picture smaller in width and height than your canvas?

Légèrement plus grande.
je ne comprend pas cette phrase “I save images in the original resolution, first in a MemoryBlock and then in the database in a BLOB.”
Pourquoi 2 manipulations ?

1 Like

Originally, the images come via a TCP/IP connection or via drag & drop or the clipboard. Then, after the saving of the data, they only come from the database.
The images are always placed in a buffer in my app. I have memory blocks in the buffer. Everything that is in the buffer is later written to the database. When the images are read from the database, they are also read back into the buffer.
Database and screen have no direct connection. In between is the data buffer. The app reads into buffer, saves from buffer and shows from buffer.
My app handles at one time 10 different images.
However, a maximum of 6 of these images are displayed at any one time. The user selects which images are to be displayed.
The images are mostly in JPEG format. When such a JPEG is received, it is placed in a memory block. Example in event DropObject:

MyMemoryBlock = obj.Picture.GetData(Picture.FormatJPEG,Picture.QualityMax)

When a MemoryBlock is placed on the screen, it is displayed as a PNG. I decided to display PNG because a lossless compressing graphic format seemed to make the most sense to me.

MyPicture = Picture.FromData(MyMemoryBlock)

The images in my app are only the smaller part of the data, there are more than 140 other fields in the buffer variables that are displayed depending on the user actions.
All data is saved from the buffer to the database at a specific point in time. In addition, there is a requirement on the part of the user that all data should be hidden on the screen under certain conditions (data security). In this case, all fields on the screen are empty, but the current data is in the buffer and can be displayed again at any time.

My pictures are at least as big as the canvas I use, but they are usually much bigger. That’s probably why I don’t have a problem with sharpness.

Salut, veuillez vérifier que vous affichez l’image à sa résolution d’origine et vérifiez si la taille du canevas correspond à la résolution de l’image. En cas de redimensionnement, utilisez des techniques pour maintenir la netteté de l’image. De plus, vérifiez si le processus de codage maintient la qualité de l’image. Vous pouvez essayer différentes options de codage ou de formats comme FormatPNG pour voir si cela améliore la netteté. Utiliser un outil d’optimisation d’image de haute qualité comme https://jpegcompressor.com/ peut également aider à maintenir la clarté de l’image.