Anti-aliasing

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
BenV
Posts: 21
Joined: Thu Dec 02, 2010 4:54 pm

Anti-aliasing

Post by BenV » Thu Feb 17, 2011 10:20 am

I've been scanning papers in black and white for a few days now and three days ago suddenly some sort of anti-aliasing is added. I've attached two files which illustrate my problem. I want the quality back to black and white and not the grayscale. I can't remember editing some code which causes this change.

These are my settings

Code: Select all

.TwainSetHideUI(True)
.TwainSetAutoFeed(True)
.TwainSetAutoScan(True)
.TwainSetPixelType(TwainPixelType.TWPT_BW)
.TwainSetBitDepth(1)
Attachments
grayscale.PNG
grayscale.PNG (8.11 KiB) Viewed 3828 times
blackwhite.PNG
blackwhite.PNG (5.84 KiB) Viewed 3828 times

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Anti-aliasing

Post by Loïc » Thu Feb 17, 2011 3:15 pm

Hi,

Please give us code to reproduce the problem. Seems you are acquiring in grayscale level and saving with JPEG compression. But with information you provided I can not confirm this.

Kind regards,

Loïc

BenV
Posts: 21
Joined: Thu Dec 02, 2010 4:54 pm

Re: Anti-aliasing

Post by BenV » Fri Feb 18, 2011 10:25 am

This is not the only code, but all image manipulation methods are included. Hopefully this helps.

Code: Select all

With pictureImaging
            .TwainSelectSource(Me.Handle)
            If .TwainOpenDefaultSource(Me.Handle) Then
                .TwainSetHideUI(True)
                .TwainSetAutoFeed(True)
                .TwainSetAutoScan(True)
                .TwainSetPixelType(TwainPixelType.TWPT_BW)
                .TwainSetBitDepth(1)
                AlterTimeArraysToTimesheetLayout()
                Do
                    scannedImage = .TwainAcquireToGdPictureImage(Me.Handle)
                    If scannedImage <> 0 Then
                        .AutoDeskew(scannedImage)
                        .Crop(scannedImage, 70, 300, 2370, 2860)
                        .RotateAngle(scannedImage, CSng(0 - .Barcode1DReaderGetBarcodeSkewAngle(1)))
                        AnalyzeTimesheet(scannedImage)
                    End If
                    Dim file As String = pdfLocation & tsName & ".pdf"
                    .SaveAsPDF(scannedImage, file, True, tsName, "ScanTool.Net OCR Component", tsName, "PDF OCR", "ScanTool.Net OCR Component")
                    timesheets = TimesheetManager.GetAllScannedTimesheets()
                    LoadDatesIntoComboBox()
                Loop While .TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED
                'OCRComponentGdViewer.Focus()
            End If
            .TwainCloseSource()
            timesheets = TimesheetManager.GetAllScannedTimesheets()
            LoadDatesIntoComboBox()
        End With

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Anti-aliasing

Post by Loïc » Sat Feb 19, 2011 3:40 pm

Hi,

OK.
Just add

Code: Select all

.ConverTo1Bpp()
after:

Code: Select all

.RotateAngle(scannedImage, CSng(0 - .Barcode1DReaderGetBarcodeSkewAngle(1)))
Hope this helps !

BenV
Posts: 21
Joined: Thu Dec 02, 2010 4:54 pm

Re: Anti-aliasing

Post by BenV » Tue Mar 01, 2011 5:54 pm

Thanks, will try it as soon as I fixed an other problem. Since I started using 7.4.0.2 (yesterday), I can't load PDF files anymore. VS tells me he can't find "GdPicture.NET.pdf.gdpdfplug" and that I should put it in the Debug folder. Although it was never nessecary in the past, I've put the dll in that folder but the problem remains.

Code: Select all

Can not find GdPicture.NET.pdf.gdpdfplug.dll. Please, copy last version of this dll into your application directory at: C:\Users\Ben\Documents\Xenon54\3.Source\X54\ScanTool.NET\ScanTool.NET\bin\Debug

Code: Select all

Dim timesheetPdf As Integer = pictureImaging.PdfReaderLoadFromFile(pdfLocation & "TS" & name & "-" & d & "-" & page & ".pdf")
Sorry for the late reply...

[EDIT]
The problem isn't caused by the new release. I've tried an older copy of 7.3 and it has the same problem. I think I messed up the references, but can't figure out what.

[EDIT 2]
Oke, the error is gone. Didn't realy do anything except a reboot. Whatever it was, it's gone and I'm glad. The solution you suggested for the alliasing works, thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest