|
The size in centimeters is not stored in the file. What you are looking for is the resolution of the image, e.g. the PPI (or DPI) setting.
PPI stands for Pixels Per Inch. Often the less accurate term DPI is used, which stands for Dots Per Inch.
From the size in pixels and the resolution, you can calculate the size of the image in inches, then you convert that in centimeters.
If you for an example get this information from the file:
int ppi = 600;<br />
int widthInPixels = 2362;<br />
int heightInPixels = 2362;
The you can calcluate the size:
double widthInInches = (double)widthInPixels / (double)ppi;
double widthInCentimeters = widthInInches * 2.54;
...and the same way for height.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks, You very helped me.
|
|
|
|
|
hi there.
i m making a interior decorator tool in c# i want to provide the mouse functionality for drag and drop and resizing the object.plz provide me some solution
khusboo
|
|
|
|
|
I have 3 classes:
class Element
{
public string name;
public string attribute;
public string innerText;
public virtual void add(Element e) { }
}
class CompositeElement : Element
{
private Element[] element;
public CompositeElement(string name, string attribute)
{
this.name = name;
}
public override void add(Element element)
{
}
}
class Root : CompositeElement
{
public Root(string name)
{
this.name = name;
}
}
When I build this project inluding 3 classes above, the error happens:"No overload for method 'CompositeElement' takes '0' arguments"
I really don't understand, can u expain to me?
Thanks,
Hung.
Hung
-- modified at 4:23 Sunday 26th March, 2006
|
|
|
|
|
When you create an object, the constructor for the class is always called, and also the constructors of all the classes that the class inherits.
You haven't specified a constructor for the Element class, so an empty constructor will automatically be created, just as if you had included this in the class:
public Element() {}
As you have specified a constructor for the CompositeElement class, no empty constructor is created. However, a call to the empty constructor of the Element class is done, just as if you had written:
public CompositeElement(string name, string attribute) : base() {<br />
this.name = name;<br />
}
The same happens in the constructor of the Root class. A call is made to the (non-existent) empty constructor of the CompositeElement class:
public Root(string name) : base () {<br />
this.name = name;<br />
}
To make the code work, you either add an empty constructor to the CompositeElement class, or specify the base constructor call in the Root constructor:
public Root(string name) : base (name, string.Empty) {<br />
}
---
b { font-weight: normal; }
|
|
|
|
|
I'm using PPC2003 with Cleartype mode screen. How i can draw a text without cleartype mode in GDI+ in CF 2.0
Nothing
|
|
|
|
|
How can I get the text of a prticular item in a listview? I searched online and found this
strItem = lvPurchaseDetails.Items(i).Text
Whats the equivalent of this in C#?
|
|
|
|
|
Mridang Agarwal wrote: Whats the equivalent of this in C#?
That looks like C# to me!
Modified at 11:02 Sunday 26th March, 2006
[edit]
Ah - I just noticed the ()s. Use [] instead.
[/edit]
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Pretty much the same:
strItem = lvPurchaseDetails.Items[i].Text;
or if you want the text of a particular subitem:
strItem = lvPurchaseDetails.Items[i].SubItems[i].Text;
|
|
|
|
|
my bad...I've been working with VB for so long that I forgot to replace the () with [].
|
|
|
|
|
and In Addition of what added above if you want to get the Focused Item or Line Text use:
//to get the first column Item
str_item = listView1.FocusedItem.Text;
//to get the first column item key
str_item_key = listView1.FocusedItem.ImageKey;
//to get all the text in the line selected
string[] str_Items = { listView1.FocusedItem.SubItems[0].Text , listView1.FocusedItem.SubItems[1].Text,...//depending on the numbers of Columns you Have Ehere Column 0 is the first column and not the first column in subitem
Have a Good Day
|
|
|
|
|
I implement Project to GIS(ESRI) and use C#, I used Map Control view Detail Map on Form. How wiil I do Use algorithm "Floyd" find the fastest/shortest way the two placesCan U share Code or Exameple for Me (send to dong.nguyendinh@gmail.com)Thanks very much AnhTin
|
|
|
|
|
I am trying to save a toolbar state to registry for later restore. But i seem unable to work with the Win32 API correctly. Can someone help? The problem is with the TBSAVEPARAMS struct. It wants a handle to the registry key (HKEY_LOCAL_MACHINE in this case) but where do i get this? I have tried passing the HKEY_LOCAL_MACHINE const 0x80000002 but i get a memory cannot be read error when i execute SendMessage TB_SAVERESTORE. I have tried the NET Registry.LocalMachine but i am unable to turn this into a pointer needed for the struct.
So what options are available? Is this impossible in NET? Below is the code i am using.
[StructLayout(LayoutKind.Sequential)]
public struct TBSAVEPARAMS
{
public UIntPtr hkr;
public string pszSubKey;
public string pszValueName;
}
[DllImport("user32.dll")]
public static extern int SendMessage(
IntPtr hWnd,
uint msg,
bool wParam,
Win32Struct.TBSAVEPARAMS lParam);
// open registrykey
// create key if needed
RegistryKey key = null;
string regKey = @"SOFTWARE\TEST";
key = Registry.LocalMachine.OpenSubKey(regKey, true);
// check errors
if (key == null)
{
return;
}
// close registry key
key.Close();
// get toolbar handle
IntPtr hWndToolBar = TrayIcons.GetIconTrayWnd();
// set up restore struct
Win32Struct.TBSAVEPARAMS tbSaveParams = new Win32Struct.TBSAVEPARAMS();
tbSaveParams.hkr = (UIntPtr)Win32Const.HKEY_LOCAL_MACHINE;
tbSaveParams.pszSubKey = regKey;
tbSaveParams.pszValueName = "Toolbar";
// save tray icon state
int result = Win32Windows.SendMessage(hWndToolBar,
(uint)Win32Const.TB_SAVERESTOREA, true, tbSaveParams);
Debug.WriteLine("result: " + result);
|
|
|
|
|
I found that one has to us process shared memory when communicating with windows OS toolbars; I thought this only applied when reading back structs in a SendMessage. Below is update of my code. I do not get any errors this time, but nothing happens. No registry key value is created, nothing. I probably need someone with PInvoke experience to OK my code ot NOT. That would help.
// get toolbar handle
IntPtr hWndToolBar = TrayIcons.GetIconTrayWnd();
// get handle to other process
// open process for all access or get access denied error
int processID = 0;
int threadID = Win32ProcessThread.GetWindowThreadProcessId(
hWndToolBar, ref processID);
IntPtr hProcess = Win32ProcessThread.OpenProcess(
Win32Const.PROCESS_ALL_ACCESS, false, processID);
// set up shared memory for struct
// make it big enough to hold dynamic data
int bufferSize = 16000;
IntPtr hGlobalBuffer = Win32Memory.VirtualAllocEx(
hProcess, IntPtr.Zero, bufferSize,
Win32Const.MEM_RESERVE | Win32Const.MEM_COMMIT,
Win32Const.PAGE_READWRITE);
// allocate local memory to hold struct
IntPtr hLocalBuffer = Marshal.AllocHGlobal(bufferSize);
// set up save struct
Win32Struct.TBSAVEPARAMS tbSaveParams = new Win32Struct.TBSAVEPARAMS();
string regKey = @"SOFTWARE\TEST";
tbSaveParams.hkr = (UIntPtr)Win32Const.HKEY_LOCAL_MACHINE;
tbSaveParams.pszSubKey = regKey;
tbSaveParams.pszValueName = "IconsBackup";
// convert struct to pointer
Marshal.StructureToPtr(tbSaveParams, hLocalBuffer, false);
// put struct in place
Win32Memory.WriteProcessMemory(hProcess, hGlobalBuffer,
hLocalBuffer, bufferSize, 0);
// save tray icon state
// no return value
Win32Windows.SendMessage(hWndToolBar,
(uint)Win32Const.TB_SAVERESTOREA, true, hLocalBuffer);
// clean up
Win32Memory.VirtualFreeEx(hProcess, hGlobalBuffer,
bufferSize, Win32Const.MEM_RELEASE);
Marshal.FreeHGlobal(hLocalBuffer);
Win32ProcessThread.CloseHandle(hProcess);
|
|
|
|
|
Hi.Im a beginner in C# and Im trying to understand the meaning of this function:
public Complex(double r, double i)
{
x = r;
y = i; }
public Complex add(Complex c)
{
x += c.x;
y += c.y;
return this;
}
Anybody can explain me in simple words what is the meaning of this?
Best regards
|
|
|
|
|
These methods are part of a class called Complex. The class seems to hold something like x and y coordinates. The first function is called the constructor for the class. This is where the x and y values are initialized based on the parameters (r, i). The second function is for adding two instances of the class together. So it takes an instance of Comnplex (called c in this case) and adds it to the current instance and returns the new object with the sum of the values.
Ex.
Complex c = new Complex(3, 4);
Complex a = new Complex(1, 2);
a = a.add(c);
Console.WriteLine(a.x + " " + a.y);
Output:
4 6
Does that help?
|
|
|
|
|
This is part of a class or structure called Complex, that handles a complex number[^].
The first method is the constructor of the class/structure. It's called when you create an object of the class/structure. It initializes the variables in the class.
The second method adds two complex numbers.
---
b { font-weight: normal; }
-- modified at 18:02 Saturday 25th March, 2006
|
|
|
|
|
I got a dummy problem while using listbox, combobox or messagebox. When I used these, every thing seems good but, I can't see the messagebox text or listbox or combobox items. I can select the items in the list or combo and get the values or messagebox works well but I can not see the message text itself or the buttons text in the messagebox. Is anyone has ever encountered such problem I know this has a very simple solution but I could not fint it.
Yakup
|
|
|
|
|
hi
i craete image in listview but the image is always in the first place how do i change the location of the image?
my code is:
imageList1.Images.Add((System.Drawing.Image)chart.GetBitmap().Clone())
for ( int i = pam.holdingArrVector.Count ; i > 0 ; i--)
{
lvi = new ListViewItem(new string[3] {" ",Convert.ToString(i-1),pam.CheckNearPivot(i-1)},i-1);
listView1.Items.Insert(0, lvi);
}
when i change listView1.Items.Insert(0, lvi);
to listView1.Items.Insert(1, lvi);
the program is falled
thanks
have a nice day
|
|
|
|
|
This is normal behavior for the listview control. If you want an image in another column you will have to: 1) use a Win32 API trick; 2) make a custom control. Look at Code Project articles for example of custom listview controls. Below is a link using a Win32 API trick.
http://www.codeproject.com/cs/miscctrl/OAKListView.asp
|
|
|
|
|
yosba221 wrote: when i change listView1.Items.Insert(0, lvi);
to listView1.Items.Insert(1, lvi);
The imageIndex parameter is the index of the image in the ImageList , not the column where you want it to appear. Your program is throwing an exception because in the above code you only add one image to the ImageList , and then you are trying to access the second one which is not there.
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|
|
I have implemeted a CollectionEditor is my custom control. It now sucessfully serializes and adds my items into the collection. Add/Remove succesully add or remove source code. However is there somthing special that needs to be done in order for VS to clean up the ColledtionEditor item code when the object is deleted by the user?
Thanks.
|
|
|
|
|
Hi all,
I am in a great trouble in drawing shapes. The problem is as follows:
I have a 8bit indexed gray scale image in a picturebox. I want to draw some filled rectangles permanently on the 8-bit image using mousedown and mousemove event of the picturebox. How should I implement this for 8-bit indexed image?
Please help me.
Thanks in advance
Anindya Chatterjee
|
|
|
|
|
Hi. i want to make a searh function in a richTextBox.
Just like in notepad or word ect ect i want a textBox there i could write something and then press searh/find and it searhes trough my text in my richTextBox.
How to do this?
Sorry for my bad english and thx.
Regards
//AeQuitaZ
PS. Thx to Yadav Pramod for the last sulution you gave me. thx.
|
|
|
|
|
If you get all the text in a string without formatting, the string class has a member IndexOf that finds the location of a substring. This[^] override will help you, since you can specify the starting position (probably where your cursor is.)
Luis Alonso Ramos
Intelectix
Chihuahua, Mexico Not much here: My CP Blog!
|
|
|
|