|
Hi,
I haven't used this myself as of late, but are you aware Graphics has an InterpolationMode property,
which accepts values such as NearestNeighbor, basically just duplicating pixels, not inventing new
ones?
If you only need to see it scaled up, use it in a Panel's OnPaint; if you really also need the
new Bitmap, do Graphics.FromImage(rnmp) then Graphics.DrawImage
|
|
|
|
|
I have tried all the items in the InterpolationMode when resizing an image with a graphics class, but none produced the result i wanted. I will try with the NearestNeighbor item again, and see if i am mistaken.
Also, could you (or anyone) please elaborate on what you ment by the OnPaint thing?
if (your.Life == lifestyles.Programming)
{
your.Cool = true;
}
else
{
your.Cool = false;
}
modified on Tuesday, July 15, 2008 6:49 PM
|
|
|
|
|
Hi,
You did not specify how exactly it does not what you want.
Three ideas:
1)
I ran a little experiment, and it seems to work fine, with one proviso: the NearestNeighbour
does duplicate pixels, but due to the nearest (not the left) source pixel, it will not duplicate
the leftmost/topmost pixel a sufficient number of times.
So to be exact, you should proceed as follows (I'll explain in one dimension):
input width w1, output width wanted w2, scalefactor f=w2/w1 (use reals for scale!)
split the output in three regions, with widths wa,wb,wc
wa=f/2 <--- represents half an input pixel
wb=(w1-1)*f
wc=w2-wa-wb <--- represents half an input pixel
now duplicate the leftmost pixel of input to wa,
duplicate the rightmost pixel of input to wc,
finally do the DrawImage scale with nearestneighbour from w1 to wb (i.e. shifted by wa)
That should put every single pixel at the right spot.
2)
I am pretty sure the complex copying of the edges could be handled by DrawImage itself,
provided you give it appropriate parameters.
3)
As an approximation you could do a two step approach:
- do DrawImage with Normal InterpolationMode for the full size;
- do DrawImage with NearestNeighbour InterpolationMode for a size that is half a pixel smaller
on all four edges of the output image (don't modify the input sizes!)
|
|
|
|
|
Thanks! With your help, i managed to figure it out. A while back, i posted this question on both ProgrammersHeaven.com and DreamInCode.net and i didn't get an answer on either site. Thanks so much!
if (your.Life == lifestyles.Programming)
{
your.Cool = true;
}
else
{
your.Cool = false;
}
|
|
|
|
|
You're welcome. Glad to be of help.
|
|
|
|
|
Hi,
I once assembled a short text giving the essentials of painting:
there are several steps to draw something so it becomes visible on the screen:
1.
decide upon what object you want to draw; it normally is a Control (e.g. a Panel) or a
Form itself. I prefer to add a Panel to a Form, then draw on the Panel.
2.
create some variables (Rectangle, struct, class, whatever) that hold the parameters of
your drawing. For a rectangle that could be top and left coordinate, and width+height,
or just a Rectangle. etc.
3.
create a Paint handler (either add your own paint handler to the Paint event, or
override the OnPaint method) for that Panel, and do all your drawing in there,
using the Graphics class and your variables.
4.
when you want to change things, modify the variables and call Panel.Invalidate() or
one of its overloads (for selective invalidation).
5.
If you want to animate things, perform the move (step 4) inside the Tick handler
of a Windows.Forms.Timer
BTW: if you need to create some objects (Fonts, Pens, Brushes, ...) either keep them
alive in class members (hence create them only once); or create them inside the Paint
handler and don't forget to call Dispose() on them.
|
|
|
|
|
Hi,
in my latest experiment, I came up with a really simple way of modifying nearestneighbour into
copy_from_left/top; it suffices to indicate half a pixel translation, as in this C# code.
The source image has size (w,h) and is translated to (x,y) and scaled up by the fraction zoomT/zoomN:
Rectangle r=new Rectangle(x, y, w*zoomT/zoomN, h*zoomT/zoomN);
g.InterpolationMode=InterpolationMode.NearestNeighbor;
g.DrawImage(image, r, -0.5f, -0.5f, w, h, GraphicsUnit.Pixel);
So instead of using the pixels 0, 1, 2, ... w-1 of the source image, I am actually using
the pixels -0.5, 0.5, 1.5, ... w-1.5 which means whenever I need something in some interval
(say the first -0.5 to 0.5) it will take the nearest integer, which is the middle of the translated
interval, i.e. the left/top of the original interval!
Can't get more simple than that.
|
|
|
|
|
I am creating a treeview dynamically.
In one .vb file - First I am reading the xml and storing the data in hashtable.
In another file - I don't want to read the xml again so I am going through hashtable and creating the nodes. How do I create Sub nodes if any. How should I store the nodes and subnodes diffrentiated in hashtable.
LK
|
|
|
|
|
|
From the reference you have given that is actually creating a custom tree view control from what i understood. But what I need is:
I cannot create a tree data structure because I have to read the xml first and store in some collection.
I have a user control where I have: a picture box control and tree view control below that. When the picture box is clicked I want to show the treeview with nodes and sub nodes if any looping through the collection. Any examples of this kind please.
Thanks for your help in advance !
LK
|
|
|
|
|
I don't know if I understood this properly, but as you want to loop through your XMLDocument and placing the items into a TreeView, you can try the following. MainTree is the TreeNode and doc is the XMLdocument.
Dim doc As New XmlDocument<br />
doc.Load(PathName)<br />
MainTree.Nodes.Clear()<br />
For Each mainroot As XmlNode In doc.ChildNodes<br />
Dim maintreenode As New TreeNode<br />
maintreenode.Text = mainroot.Name<br />
MainTree.Nodes.Add(maintreenode)<br />
For Each subnode As XmlNode In mainroot.ChildNodes<br />
Dim subroot As New TreeNode<br />
subroot.Text = subnode.Name<br />
maintreenode.Nodes.Add(subroot)<br />
<br />
etc..<br />
<br />
Next<br />
Next<br />
Hope this helps you out,
--Zaegra--
Motivation is the key to software development.
|
|
|
|
|
Member 2260473 wrote: From the reference you have given that is actually creating a custom tree view control from what i understood.
Ähm, no. Its a Tree-Datastructure, no Control. And I build a Tree from it, which each leafs type String.
Why cant u create a similar tree datastructure ("Value" can be any type, so I suppose, also the datatype u need), and fill it by reading the xml?
And from that tree build ur UserControl-Treeview, and do the other things, u want to do.
|
|
|
|
|
This is a silly question, but is there a way to get datagridview columns names in intelli-sense as properties?
For example:
grdUsers.Rows(vlngUserRow).Cells("SoftwareSystemSecurityID").Value
Is it possible to do something like (property vs. having to type the column name)?
grdUsers.Rows(vlngUserRow).Cells.SoftwareSystemSecurityID.Value
Thanks for any help/suggestions!
|
|
|
|
|
If you added the column at design time, you could reference it like this:
grdUsers.Rows(vlngUserRow).Cells(SoftwareSystemSecurityID.Index).Value
But if you get the column because you had set the grid's datasource to a dataset/datatable that contains the column, this doesn't work.
Hope this helps.
|
|
|
|
|
Score!
Don't know how I missed that. Thanks!
|
|
|
|
|
There are 2 list box and a horizontal Splitter. When I resize the window, both the listbox does not resize proportionally. The top listbox remains in same height, the bottom listbox gets resized.
The properties for splitter is
cursor - HSplit
Dock - Top
The properties for listbox1 is
Dock - Top
Anchor - Top,Left
The properties for listbox2 is
Dock - Fill
Anchor - Top,Left
Changing the dock or Anchor do not work out..
|
|
|
|
|
Hi,
Since the Dock property is set to Top, the width will resize in proportion to the window size.
Therefore, in order to get the desired resolution try setting the Dock property of first ListBox to Fill. This will ensure that the ListBox resizes proportionally to the window.
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
I tried that option too.
If both the listbox is set to Fill, then i can able to view only one list box.
This option is not working
|
|
|
|
|
In how many forums did you ask that question?
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
hi all,
i want to create Backup file (.bak file of Sql Server) programmatically .How can Achieve this task in vb.net.Also how can i restore the data programmatically in database? I use SqlExpress which is supplied with Visual Studio.
|
|
|
|
|
You can write practically any SQL into the SqlCommand object. All you need to do is write the SQL to perform the back up and perform ExecuteNonQuery() on the SqlCommand object.
|
|
|
|
|
sir,
can you explore this thing in detail or provide some useful link for this task ?
|
|
|
|
|
Hi, I am now working on a data compare and copy for datagrid. Below i have the codes the open up this csv file and attached it to the datagrid1.
I am now finding a way to
1. Type in "123123" into the textbox
2. Click a button
3. Compare it with the datagrid1(which has the opened csv file) or compare directly with csv file
4. Copy the whole row on which the "123123" is found and paste into another field or datagrid for display
Public Function Import()<br />
<br />
Dim myPath As String = "c:\testing.csv"<br />
<br />
Try<br />
<br />
Dim objDataSet As System.Data.DataSet<br />
Dim objAdapter As System.Data.OleDb.OleDbDataAdapter<br />
<br />
strConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" & myPath & " '; " & "Extended Properties=Excel 8.0;")<br />
objAdapter = New System.Data.OleDb.OleDbDataAdapter("select * from [sheet1$]", strConnection)<br />
objDataSet = New System.Data.DataSet<br />
objAdapter.Fill(objDataSet)<br />
DataGrid1.DataSource = objDataSet.Tables(0).DefaultView<br />
strConnection.Close()<br />
<br />
Catch ex As Exception<br />
<br />
Dim er As String<br />
<br />
strConnection.Close()<br />
<br />
End Try
thanks
|
|
|
|
|
Use the objDataSet.Tables(0).Select("ColumnName = "& YourTextBox.Text")
This will return DataRow Collection that you can manage the way you wish
Best Regards
3ala2
|
|
|
|
|
hy everyone!
i do have problems debugging my webservice. it compiles propperly but when i choose "debug > start new instance" in the solution explorer then i get the message "Auto-attach to process '[2704] aspnet_wp.exe' on machine 'devVS2003' failed. Error code 0x8013134b".
When I manually attach the process to aspnet_wp.exe and start it in debug mode (common language runtime checked) i get a dialog "unable to attach to the process" but no message why.
does anyone of you have an idea how to solve this?
when i googled for it i just found similar postings but no solution to these problems which could help me.
thanks for any advice.
stephan.
|
|
|
|