at certain coordinates, the coordinates are expressed in millimeters and are stored in an archive,
the procedure must also calculate the left margin and the top margin
which is also used by the image
I can't center the pixels in the right position, I even asked Open Ai without having satisfactory results
for example for the first 10 boxes the data is the following
number1=Box Numbers Panel 1|3.6|21.4
number2=Box Numbers Panel 2|9.7|21.4
number3=Box Numbers Panel 3|15.8|21.4
number4=Box Numbers Panel 4|21.9|21.4
number5=Box Numbers Panel 5|28.0|21.4
number6=Box Numbers Panel 6|34.1|21.4
number7=Box Numbers Panel 7|40.2|21.4
number8=Box Numbers Panel 8|46.3|21.4
number9=Panel numbers box 9|52.4|21.4
number10=Panel numbers box 10|58.5|21.4
to be clear the first pixel must be positioned on the x,y coordinate 3.6 21.4
the pixel can have a width of 2 mm
The horizontal distance between pixels must be 6.1mm and the vertical distance 5.9mm
test to try
- Code: Select all Expand view
#include "fivewin.ch"
FUNCTION StampaPixel()
LOCAL aDati := { ;
{"Pannello numeri casella 1", 3.6, 21.4}, ;
{"Pannello numeri casella 2", 9.7, 21.4}, ;
{"Pannello numeri casella 3", 15.8, 21.4}, ;
{"Pannello numeri casella 4", 21.9, 21.4}, ;
{"Pannello numeri casella 5", 28.0, 21.4}, ;
{"Pannello numeri casella 6", 34.1, 21.4}, ;
{"Pannello numeri casella 7", 40.2, 21.4}, ;
{"Pannello numeri casella 8", 46.3, 21.4}, ;
{"Pannello numeri casella 9", 52.4, 21.4}, ;
{"Pannello numeri casella 10", 58.5, 21.4}, ;
{"Pannello numeri casella 11", 3.6, 27.3}, ;
{"Pannello numeri casella 12", 9.7, 27.3}, ;
{"Pannello numeri casella 13", 15.8, 27.3}, ;
{"Pannello numeri casella 14", 21.9, 27.3}, ;
{"Pannello numeri casella 15", 28.0, 27.3}, ;
{"Pannello numeri casella 16", 34.1, 27.3}, ;
{"Pannello numeri casella 17", 40.2, 27.3}, ;
{"Pannello numeri casella 18", 46.3, 27.3}, ;
{"Pannello numeri casella 19", 52.4, 27.3}, ;
{"Pannello numeri casella 20", 58.5, 27.3} ;
}
LOCAL nMargineSinistro := 10, ; // Margine sinistro per l'immagine
nMargineSuperiore := 10, ; // Margine superiore per l'immagine
nOffsetY := 5.9, ; // Offset verticale per i quadratini
nOffsetX := 6.1, ; // Offset orizzontale per i quadratini
nPixelLarghezza := 2, ; // Larghezza del pixel in mm
nPixelAltezza := 2, ; // Altezza del pixel in mm
nX, nY, oBrush, aRect, n
LOCAL oPrn
// Definisci il pennello per il pixel
DEFINE BRUSH oBrush COLOR CLR_BLACK
// Inizio della stampa con anteprima
PRINT oPrn PREVIEW
PAGE
// Stampa l'immagine di sfondo (se necessaria)
PrintImage(0.3, 0.33, 9.8, 21, ".\bitmaps\schedina2.jpg", nMargineSuperiore, nMargineSinistro, oPrn)
// Ciclo attraverso i dati per stampare i pixel
FOR n := 1 TO LEN(aDati)
nX := (aDati[n][2] * 10) + nMargineSinistro + (nOffsetX * (n - 1)) // Posiziona il pixel in base alla coordinata X originale
nY := (aDati[n][3] * 10) + nMargineSuperiore + (nOffsetY * (IF(n <= 10, 0, 1))) // Aggiunge l'offset Y in base alla riga
// Crea un rettangolo da riempire
aRect := { nY, nX, nY + (nPixelAltezza * 10), nX + (nPixelLarghezza * 10) }
// Disegna il rettangolo (pixel)
oPrn:FillRect(aRect, oBrush)
NEXT
ENDPAGE
ENDPRINT
RETURN NIL
FUNCTION PrintImage(nTop, nLeft, nRight, nBottom, cFile, nMargineSuperiore, nMargineSinistro, oPrn)
LOCAL lStretch := .f.
LOCAL nAlpha := 0
LOCAL lTransp := .f.
LOCAL lGray := .f.
// Usa l'oggetto di stampa già presente
oPrn:Cmtr2Pix(@nTop, @nLeft)
oPrn:Cmtr2Pix(@nBottom, @nRight)
oPrn:SayImage(nTop + nMargineSuperiore, nLeft + nMargineSinistro, cFile, nRight, nBottom)
RETURN NIL
schedina.jpg to insert on .\bitmaps\ folder