WIA 2.0 HP ScanJet 7650 specific problems - windows-7

I'm having WIA 2.0 problems on Windows 7. On windows XP with wia 2.0 (version from Windows 7 everything works ok)
One device, HP ScanJet 7650 refuses to have its scanning resolution set to anything above 100. When I try to set either of WIA properties
6147 _ Horizontal Resolution
6148 _ Vertical Resolution
to anything above 100 I get:
A first chance exception of type
'System.ArgumentException' occurred
Value does
not fall within the expected range.
After that, value of property is 850 (?) and scanner ignores it and scans at 100 dpi
On this same WIA 2.0 and Lexmark X340 MFP I can set scanning resolution without any problems.
Using the same scanner (HP ScanJet 7650) on WIA 1.0 I had no problems. Also, scanning from this scanner using Windows scan applet (from Devices and printers) it can scan in DPIs well above 100. So, I must be doing something wrong.
Here is complete list of properties available on WIA 2.0 for HP ScanJet 7650:
4098 _ Item Name
4099 _ Full Item Name
4101 _ Item Flags
4120 _ Color Profile Name
6154 _ Brightness
6155 _ Contrast
71692 _ Private Highlight Level
71694 _ Private Midtone Level
71693 _ Private Shadow Level
71695 _ Private Gamma
71699 _ Private Saturation
71696 _ Private Hue X
71697 _ Private Hue Y
71698 _ Private Sharpen Level
6159 _ Threshold
6147 _ Horizontal Resolution
6148 _ Vertical Resolution
71687 _ Private Default Resolution
71688 _ Private Quality Resolution
6149 _ Horizontal Start Position
6150 _ Vertical Start Position
6151 _ Horizontal Extent
6152 _ Vertical Extent
4112 _ Pixels Per Line
4113 _ Bytes Per Line
4114 _ Number of Lines
4116 _ Item Size
4118 _ Minimum Buffer Size
6146 _ Current Intent
4103 _ Data Type
4104 _ Bits Per Pixel
4110 _ Bits Per Channel
4109 _ Channels Per Pixel
4111 _ Planar
4107 _ Compression
4108 _ Media Type
4106 _ Format
4105 _ Preferred Format
4123 _ Filename extension
4102 _ Access Rights
6153 _ Photometric Interpretation
71686 _ Private Source Depth
71683 _ Private Preview
71689 _ Private Exposure Method
71722 _ Private Smoothing
71723 _ Private Color Enhanced
71685 _ Private TMA Method
71701 _ Private Defaults
71702 _ 71702
71703 _ 71703
71704 _ 71704
71711 _ 71711
71712 _ 71712
71705 _ 71705
71706 _ 71706
71707 _ 71707
71708 _ 71708
71709 _ 71709
71710 _ 71710
71721 _ 71721
71713 _ 71713
71714 _ 71714
71715 _ 71715
71716 _ 71716
71717 _ 71717
71718 _ 71718
71719 _ 71719
71720 _ Private Property

Have you looked at this question?
Try set WiaImageBias.MaximizeQuality

The Property Object has two properties, SubTypeMax and SubTypeMin, that you may want to check before setting the value property.

Related

How to change comments in excel file with go

I'm using the excelize library.
newfile, _ := excelize.OpenFile("filename.xlsx")
println(newfile.GetComments())
//map[Sheet1:[{Author 0 A2 comment1}]]
_ = newfile.InsertRow("Sheet1", 1)
println(newfile.GetComments())
//map[Sheet1:[{Author 0 A2 comment1}]]
the coordinates of my comment comment1 have not changed. How to solve this problem?

MagickWand 7 API: how to port MagickSetImageClipMask call

ImageMagick 7 dropped this call, but I can't find any example of how to replicate its functionality in the new version. My aim is to composite two images with a mask. Here's vastly simplified go code for what I was doing in version 6.
func CleanUpImage(originalImage, maskImage *imagick.MagickWand) (*imagick.MagickWand, error) {
err error;
targetImage = imagick.NewMagickWand();
pw = imagick.NewPixelWand();
width = originalImage.GetImageWidth();
height = originalImage.GetImageHeight();
_ = pw.SetColor("white");
_ = targetImage.NewImage(width, height, pw);
_ = targetImage.SetImageClipMask(maskImage);
_ = targetImage.CompositeImage(originalImage, imagick.COMPOSITE_OP_COPY, 0, 0);
return targetImage, err;
}
Can anyone give me guidance about getting this running in version 7?
Thanks!
I'm unfamiliar with the GO bindings, but MagickSetImageClipMask() was replaced with MagickSetImageMask() in ImageMagick-7. The only difference is that users can define the direction (Read/Write) of the mask.
To match ImageMagick-6's ClipMask, you would set the image mask to write.
MagickSetImageMask(image_wand, WritePixelMask, mask_wand);

Figuring out different CoNLL format

I am trying to generate a conll file from Stanford Core NLP, which then can be used as an input to Semafor (as semafor accepts conll file only).
The generated file looks like this:
1 My my PRP$ O 2 nmod:poss
2 kitchen kitchen NN O 5 nsubj
3 no no RB O 4 neg
4 longer longer RB O 5 advmod
5 smells smell VBZ O 0 ROOT
6 . . . O 5 punct
When I use this file, the Semafor server returns illegalArgument exception since the format is slightly different. Their example conll file looks like this:
1 My _ PRP$ PRP$ _ 2 NMOD _ _
2 kitchen _ NN NN _ 5 SBJ _ _
3 no _ RB RB _ 5 ADV _ _
4 longer _ RB RB _ 3 AMOD _ _
5 smells _ VBZ VBZ _ 0 ROOT _ _
6 . _ . . _ 5 P _ _
It seems that I can control the output by defining the keys. The default keys are ID, FORM, LEMMA,POSTAG,NER, HEAD, DEPREL. However, I don't know the keys for the example conll file provided by Semafor. Please guide me how I might convert the generated file format into Semafor example file format.
I believe that Semafor can generate its own conll file in the format that it needs. We use Stanford Core NLP just to split a document into sentences per line, and then use Semafor itself to generate the conll file.

Vb6 Drag and Drop HTML data

In Visual basic 6, clipboard has various formats. To retrieve HTML data from the clipboard, this works great: https://support.microsoft.com/en-us/kb/274326
Now my question is, how can I get HTML information from dragged data and not the clipboard?
for example,
I'd like to have a multi-line textbox, that when I drag content from a webpage - into the textbox - the textbox will show the HTML retrieved from the OLE Dragging information, and not as vbCFtext.
I'v tried using the same technique as in the link above but instead of GetClipboardData - use Data.GetData(RegisterClipboardFormat("HTML Format")) [which is coming from Picture1_OLEDragDrop(...]
but I get an over flow error.
I have searched all over the web for a solution. anybody out there?
Edited: The above was answered, Thanks!
Adding:
Thank you very much! What would be the right way now to reverse that? meaning, to drag from a text box (that contains HTML) - and set it for dragging in HTML mode?
when I simply use this:
Private Sub Text1_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
'Data.SetData StrConv(Text1.Text, vbFromUnicode), (CF_HTML)
Data.SetData Text1.Text, (CF_HTML)
End Sub
I get an error:
"Non-intrinsic OLE drag and drop formats used with SetData require Byte array data. GetData may return more bytes than were given to SetData (Error 675)"
What would be the accurate way to send back the data?
and note that in could have Unicode characters.
will I have to use memory copy and others to get this to work? I'l appreciate your help very much!
Your problem is that RegisterClipboardFormat returns a Long (actually a uint), but clipboard formats are ushort (unsigned integer) values. Since we have no such type in VB6, our DataObject types expect Integer values. Thus we have to play a few more games:
Option Explicit
Private Declare Function RegisterClipboardFormat Lib "user32" _
Alias "RegisterClipboardFormatW" ( _
ByVal lpString As Long) As Long
Private CF_HTML As Integer
Private Sub Form_Initialize()
Dim Temp As Long
Temp = RegisterClipboardFormat(StrPtr("HTML Format"))
CF_HTML = CInt(Temp And &H7FFF&) Or IIf(Temp And &H8000&, &H8000, 0)
End Sub
Private Sub Text1_OLEDragDrop( _
Data As DataObject, _
Effect As Long, _
Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)
If Effect And vbDropEffectCopy Then
Text1.Text = StrConv(Data.GetData(CF_HTML), vbUnicode)
End If
End Sub
Private Sub Text1_OLEDragOver( _
Data As DataObject, _
Effect As Long, _
Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single, _
State As Integer)
If Data.GetFormat(CF_HTML) Then
Effect = vbDropEffectCopy
Else
Effect = vbDropEffectNone
End If
End Sub

XDocument producing invalid XML

I have this code
Dim doc As XDocument = New XDocument( _
New XDeclaration("1.0", "utf-8", "yes"), _
New XElement("transaction", _
New XElement("realm", wcRealm), _
New XElement("password", wcPassword), _
New XElement("confirmation_email", wcConfEmail), _
New XElement("force_subscribe", wcSubscribe), _
New XElement("optout", wcOptOut), _
New XElement("command", _
New XElement("type", wcType), _
New XElement("list_id", wcListId), _
From trans As DataRow In table.Rows _
Order By trans("last") _
Select New XElement("record", _
New XElement("email", trans("email")), _
New XElement("first", trans("first")), _
New XElement("last", trans("last")), _
New XElement("company", trans("company")), _
New XElement("address_1", trans("address_1")), _
New XElement("address_2", ""), _
New XElement("city", trans("city")), _
New XElement("state", trans("state")), _
New XElement("zip", trans("zip")), _
New XElement("country", trans("country")), _
New XElement("phone", trans("phone")), _
New XElement("fax", trans("fax")), _
New XElement("custom_source", trans("source")), _
New XElement("custom_vmail_expire_date", "")))))
'' # Save XML document at root.
doc.Save("c:\vj" & saveDate & ".xml")
which works fine a produces the proper XML file BUT I run it through a validator and get this error.
Sorry, I am unable to validate this document because on line 1 it contained one or more bytes that I cannot interpret as us-ascii (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication.
The error was: ascii "\xEF" does not map to Unicode
What could be causing that?
The problem is that you have an UTF-8 file that you are trying to validate as ASCII. Those 2 bytes are the unicode headers.
The validator doesn't support UTF8/UCS-2. Either save the file as ascii (which will break, as the xml says it's utf-8) or find a validator that was created within the last 5 years.
EDIT:
Note: If you want to save it as US Ascii, use new XDeclaration("1.0", "us-ascii", "yes")
The file is saved as UTF-8 with the byte-order-marker character at the start (this character begins with the octet 0xEF).
You validator for some reason seems not to like this character. Strictly speaking this character is whitespace and it is invalid to have whitespace preceeding the XML declaration. However, most parsers I know will skip it as being simply an indicator of unicode encoding and not treat it as content.

Resources