Link to home
Start Free TrialLog in
Avatar of rionroc
rionrocFlag for United States of America

asked on

Is there a way to know if how many the same graphics/picture in 1 paper printed

Is there a way to know if how many the same graphics/picture in 1 paper printed?

Example:
This Paper has 2 different images; first image has 6 same graphics, second image has only 1 graphics.

A pop-up message will say "6 same images in 3x2 size, and 1 image with 6x5 size"

Can anyone share a code to do this in .net vb or c#.
printsample.JPG
Avatar of Member_2_4694817
Member_2_4694817

This depends a lot on the input, i.e what you call "one paper"
- a html page? Easy! Look for identical <img src=".."> entries...
- an image, possible with lossy compression (jpg)? Do able, but requires quite a bit of programming ...
- a document (pdf, MS-Word, ...)? Requires knowledge about the (usually proprietary) file format...
Avatar of rionroc

ASKER

Hello

Thank you.


What I'm asking is it possible to detect when a paper being printed with 6 images in 2x2 size and 1 image in 5x5 size, will show a message after printing like: " 6 same images in 2x2 size, and 1 image with 5x5 size "


Can anyone share a code to do this in .net vb or c#.

:)
rionroc
Again, what do you mean with "a paper being printed"?
Avatar of rionroc

ASKER

Hello


After a paper was printed.

A printer just finished printing the paper with "6 images in 2x2 size and 1 image in 6x5 size".

A detection will show message "6 images in 2x2 size and 1 image in 6x5 size printed on a paper".

A printer spool message that "6 images in 2x2 size and 1 image in 6x5 size printed on a paper".


I hope you got that Sir!

:)
So that would apply to printing from any application.
It seems you need to write a custom printer driver for that which would analyse the printing commands - or to be more general, prepare the page size bitmap and check the output for identically looking portions while sending the result to the original printer driver.
Tough, but doable.
Avatar of rionroc

ASKER

Thanks


Hopefully this question can also be answered by some other programming experts here in EE.


Great is our GOD.
:)
rionroc
Avatar of rionroc

ASKER

OK


Since this question is so hard to answer with a code:

I would like to change it to give the points to easily.
WHATS wrong with this code:

I'm not interested to debug it or trace it, and want someone too.

Even if I change the thumbWidth and thumbHeight value, still the image on the thumbnails are not clear?  But if I view it in windows explorer or any software the thumbnails are clear.


Imports System
Imports System.IO
Imports System.Windows.Forms
 
Public Class Form1
    Inherits System.Windows.Forms.Form
 
#Region " Windows Form Designer generated code "
 
    Public Sub New()
        MyBase.New()
 
        'This call is required by the Windows Form Designer.
        InitializeComponent()
 
        'Add any initialization after the InitializeComponent() call
 
    End Sub
 
    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
 
 
    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents FolderBrowserDialog1 As System.Windows.Forms.FolderBrowserDialog
    Friend WithEvents ListView1 As System.Windows.Forms.ListView
    Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Friend WithEvents Button2 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog
        Me.ListView1 = New System.Windows.Forms.ListView
        Me.ProgressBar1 = New System.Windows.Forms.ProgressBar
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
        Me.Button2 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(112, 8)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(96, 24)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Select Images"
        '
        'ListView1
        '
        Me.ListView1.AllowDrop = True
        Me.ListView1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.ListView1.Location = New System.Drawing.Point(8, 65)
        Me.ListView1.Name = "ListView1"
        Me.ListView1.Size = New System.Drawing.Size(594, 466)
        Me.ListView1.TabIndex = 3
        Me.ListView1.UseCompatibleStateImageBehavior = False
        '
        'ProgressBar1
        '
        Me.ProgressBar1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.ProgressBar1.Location = New System.Drawing.Point(8, 38)
        Me.ProgressBar1.Name = "ProgressBar1"
        Me.ProgressBar1.Size = New System.Drawing.Size(594, 21)
        Me.ProgressBar1.TabIndex = 4
        Me.ProgressBar1.Visible = False
        '
        'OpenFileDialog1
        '
        Me.OpenFileDialog1.Multiselect = True
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(8, 8)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(96, 24)
        Me.Button2.TabIndex = 5
        Me.Button2.Text = "Select Folder"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(610, 551)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.ProgressBar1)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.ListView1)
        Me.Name = "Form1"
        Me.Text = "Browse Images via Thumbnails in a ListView"
        Me.ResumeLayout(False)
 
    End Sub
 
#End Region
 
Private Const thumbWidth As Byte = 128 '<<<<<< CHANGEd TO 50 still fade
Private Const thumbHeight As Byte = 128 '<<<<<< CHANGEd TO 50 still fade
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.Multiselect = True
        OpenFileDialog1.Filter = ("Supported Files|*.gif;*.jpg;*.bmp")
        If OpenFileDialog1.ShowDialog = DialogResult.OK Then
            If OpenFileDialog1.FileNames.Length > 0 Then
                updateImages(OpenFileDialog1.FileNames)
            End If
        End If
    End Sub
 
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
            updateImages(Directory.GetFiles(FolderBrowserDialog1.SelectedPath))
        End If
    End Sub
 
    Private Sub updateImages(ByVal fileNames() As String)
        Dim fi As FileInfo
        Dim fileName As String
        Dim thumbEntry As ListViewItem
        Dim imageList1 As ImageList = New ImageList
        Dim p As Integer, i As Integer, numFiles As Integer = fileNames.Length
        Dim myCallback As Image.GetThumbnailImageAbort = _
                New Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
 
        ListView1.Items.Clear()
        imageList1.ImageSize = New Size(thumbWidth, thumbHeight)
        ListView1.LargeImageList = imageList1
        ListView1.SmallImageList = imageList1
 
        ListView1.BeginUpdate()
        ProgressBar1.Value = 0
        ProgressBar1.Visible = True
        i = 0
        For Each fileName In fileNames
            fi = New FileInfo(fileName)
            If fi.Extension.ToUpper.Equals(".BMP") Or _
                    fi.Extension.ToUpper.Equals(".JPG") Or _
                    fi.Extension.ToUpper.Equals(".GIF") Then
                Try
                    imageList1.Images.Add(Image.FromFile(fi.FullName).GetThumbnailImage(thumbWidth, thumbHeight, myCallback, IntPtr.Zero))
                    thumbEntry = New ListViewItem
                    thumbEntry.Text = fi.Name
                    thumbEntry.ImageIndex = imageList1.Images.Count - 1
                    ListView1.Items.Add(thumbEntry)
                Catch ex As Exception
                    MsgBox(fi.FullName & vbCrLf & vbCrLf & ex.Message, MsgBoxStyle.Information, "Error Loading Image")
                End Try
            End If
            i = i + 1
            p = CInt(i / numFiles * 100)
            ProgressBar1.Value = p
            Application.DoEvents()
        Next fileName
        ProgressBar1.Visible = False
        ListView1.EndUpdate()
    End Sub
 
    Private Function ThumbnailCallback() As Boolean
        Return False
    End Function
 
End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of rionroc
rionroc
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial