Image resizes itself

Issues related to label design (working with databases, data processing, RFID encoding etc.) and printing (from NiceLabel Express, NiceLabel Pro, NiceForm and NicePrint)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
SimonD
Enthusiast
Posts: 17
Joined: Thu May 23, 2013 8:31 am

Image resizes itself

Post by SimonD » Thu Jul 11, 2013 10:06 am

Hi All,

I got a small problem over here.
I coded my own Labelprintig Software with Visual Basic 2010 Express - everything works fine beside the the image on the Label.
Everytime when i load the next data for the label - the imagevariable resizes itself and gets smaller - take a look on the pictures 1 - 2 - 3

Is this a known problem?

I load the data in this way -> Check the variablenames on the label -> compare it with an XMLfile - where the cellnames for the excelfile with the data is saved and then load the data from the excelfile

the code for that:

Code: Select all

                Try
                    LabelIntf = Nice.LabelOpenEx(LabelFileName)
                    LabelIntf.Variables.Free()
                    Variablen = GetVariables(Groesse) 'Groesse = size of the label
                    For i = 0 To Variablen.Length - 1
                        If Variablen(i) = "Logo" Then 'Logo is the imagevariable - i set prefix and suffix for the path to the file
                            LabelIntf.Variables.FindByName("Logo").Prefix = XmlFile.Settings.Item("Einstellungen")("Pfad")("Logo").Value
                            LabelIntf.Variables.FindByName("Logo").Suffix = ".png"
                        End If
                        LabelIntf.Variables.FindByName(Variablen(i)).SetValue(CStr(oExcel.Range(XmlFile.Settings.Item("Layout")(Groesse)(Variablen(i)).Value).Value))
                    Next
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
The code for reading the variables on the label I found here in the forum - i changed it to a function to return the variables in an array

Code: Select all

    Function GetVariables(ByVal Feld As String)
        LabelIntf = Nice.LabelOpenEx(XmlFile.Settings.Item("Einstellungen")("Pfad")("Layout").Value & Feld & ".lbl")
        Dim I As Integer
        Dim Variablen(LabelIntf.Variables.Count - 1) As String
        'lb_variablen.Items.Clear()
        'Get variables
        For I = 1 To LabelIntf.Variables.Count
            ' We are only interested in prompted variables
            If LabelIntf.Variables.Item(I).VarType = vtPrompt Then
                Variablen(I - 1) = (LabelIntf.Variables.Item(I).Name)
            End If
        Next
        Return Variablen
    End Function
The code for the preview:

Code: Select all

    Sub getPreview()
        Dim Successful As Boolean
        If Not pb_preview.Image Is Nothing Then
            pb_preview.Image.Dispose()
            Kill(PreviewFileName)
        End If

        PreviewFileName = VB.Left(LabelFileName, Len(LabelFileName) - 4) & ".bmp"
        LabelIntf.Print("1, 0, 0, 0, SIMULATE, STOPUPDATES")
        Successful = LabelIntf.GetLabelPreview(PreviewFileName, pb_preview.Width, pb_preview.Height)
        If Successful Then
            pb_preview.Image = System.Drawing.Image.FromFile(PreviewFileName)
            pb_preview.Visible = True
        End If
    End Sub
I already tried to fix the position on the label - but that didn't help. When i restart the programm it starts with the original size.

Hope you could help me

Kind Regards
Simon
Attachments
M.lbl
Label
(154 KiB) Downloaded 122 times
3.JPG
3.JPG (16.97 KiB) Viewed 1770 times
2.JPG
2.JPG (17.01 KiB) Viewed 1770 times
1.JPG
1.JPG (18.08 KiB) Viewed 1770 times

SimonD
Enthusiast
Posts: 17
Joined: Thu May 23, 2013 8:31 am

Re: Image resizes itself

Post by SimonD » Thu Jul 11, 2013 1:45 pm

Found the solution by accident ;)

Code: Select all

LabelIntf.Print("1, 0, 0, 0, SIMULATE, STOPUPDATES")
somehow the simulation causes the resize of the image.

Regards
Simon

primoz
NiceLabel Development
NiceLabel Development
Posts: 22
Joined: Wed Nov 29, 2006 2:10 pm

Re: Image resizes itself

Post by primoz » Wed Jul 17, 2013 2:47 pm

Hi,

I cannot reproduce the problem with my generic test application using random graphics file, can you send me the graphics file that is causing the problems.

Post Reply