|
Hmm cant find my error here.
I have the following code
private static Image ImagesToTiff(Image[] pages)
{
try
{
EncoderParameters ep = new EncoderParameters(2);
ep.Param[0] = new EncoderParameter(Encoder.SaveFlag, (long)EncoderValue.MultiFrame);
ep.Param[1] = new EncoderParameter(Encoder.ColorDepth, (long)ColorDepth.Depth32Bit);
MemoryStream ms = new MemoryStream();
Bitmap Tiff = new Bitmap(pages[0]);
Tiff.Save(ms, GetEncoder(ImageFormat.Tiff), ep);
ep.Param[0] = new EncoderParameter(Encoder.SaveFlag, (long)EncoderValue.FrameDimensionPage);
for (int i = 1; i < pages.Length; i++)
{
Tiff.SaveAdd(pages[i], ep);
if (i == pages.Length - 1)
{
EncoderParameters epx = new EncoderParameters(2);
epx.Param[0] = new EncoderParameter(Encoder.SaveFlag, (long)EncoderValue.Flush);
epx.Param[1] = new EncoderParameter(Encoder.SaveFlag, (long)EncoderValue.LastFrame);
Tiff.SaveAdd(epx);
}
}
return Image.FromStream(ms);
}
catch (Exception)
{
throw;
}
}
public static void DemoTheCode()
{
Bitmap b = new Bitmap(100,100);
Bitmap[] imgs = new Bitmap[2];
Graphics g = Graphics.FromImage(b);
g.FillRectangle(Brushes.Red,0,0,100,100);
g.Save();
imgs[0] = b;
g.FillRectangle(Brushes.Blue,0,0,100,100);
g.Save();
imgs[1] = b;
Image MyTiffOfTwoPages = ImagesToTiff(imgs);
int Pages = MyTiffOfTwoPages.GetFrameCount(FrameDimension.Page);
MyTiffOfTwoPages.Save(@"C:\Demo.Tiff", ImageFormat.Tiff);
}
Please look at the 2 last lines of code to see what i mean...
Does anyone know why ? am i missing somwthing here ?
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
I cannot identify the specific problem but you might try looking at Save images into a multi-page TIFF file or add images to an existing TIFF file[^] here on CodeProject. There are several other articles here, this is just the first that I found.
Good luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks for the reply Henry.
Before posting this, I did find all Tiff related article on CP (I hate it to, when people dont do the research themselfs ), but none, did what I did.
I have no problem with the code, if I write the images directly to a file, and dont use the MemoryStream, but in my case i have to make the image in memory, as it will be put into an SQL server as blob data. and later on it will have to be saved to another filesystem.
But ill be searching on. again thx for the reply
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
Hello,
I have window application in windows7. It updates datagrids from sql DB.
In windows XP it works fine .
In windows7- there are computers it works fine and there are computers the application itself loads but it can't connect to the sql server (and update the datagrids). I have .net framework installed on both computer.
What can be the problem?
|
|
|
|
|
Where is the SQL server you are trying to connect to? In same network or any other?
|
|
|
|
|
If the app loads then I would say it isn't a problem with the app, Windows7 or the .net framework. I seems more likely that the issue is with the machine being able to connect to the database. Check for connectivity issues. If you're using integrated security and using the windows login account perhaps these people don't have the proper rights.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You should post your code or the error generated so we can know what we're dealing with
|
|
|
|
|
I am using server username and password (not windows).
The server is located on the same network that the computer.
The problem is that on some windows7 computer all works fine and on some other it cann't connect to DB. I am not using windows credentials to connect to the DB but the server credentials.
|
|
|
|
|
You'll have to check the connectivity on the machine that don't work. Perhaps it a firewall issue that is preventing connecting to the database server
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
One, you responded to the wrong post
Two, the code is irrelevant
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi
Im having a problem getting the code below to work.
compressorHnd = Avi.ICOpen(Avi.FOURCC.ICTYPE_VIDEO, Avi.FOURCC.DIVX, Avi.ICMODE.ICMODE_COMPRESS);
pCV = new Avi.COMPVARS();
pCV.cbSize = Marshal.SizeOf(pCV);
pCV.hic = compressorHnd;
pCV.dwFlags = 1;
pCV.fccHandler = Avi.FOURCC.DIVX;
pCV.fccType = Avi.FOURCC.ICTYPE_VIDEO;
outbi = new Avi.BITMAPINFOHEADER();
outbi.biSize = Marshal.SizeOf(outbi);
outbi.biWidth = 640;
outbi.biHeight = 480;
outbi.biPlanes = 1;
outbi.biBitCount = 24;
outbi.biCompression = 0;
Avi.ICSeqCompressFrameStart(pCV, ref outbi);
bool key = false; long size = 0;
IntPtr r = (IntPtr)Avi.ICSeqCompressFrame(pCV, 0, image.ToArray(), ref key, ref size);
The code causes an "System.AccessViolationException: Attempted to read or write protected memory" exception on the last line.
ICSeqCompressFrame is imported using the code,
[DllImport("MSVFW32.dll")]
public static extern int ICSeqCompressFrame(
COMPVARS pc,
int uiFlags,
byte[] lpBits,
ref bool pfKey,
ref long plSize
);
Can anyone help me out?
|
|
|
|
|
Hi,
AFAIK you can't pass arrays like that, you need to offer some help. Here[^] is a little article explaining some ways that do work.
|
|
|
|
|
|
Hello,
is there any thumbnail control that supports the sorting of thumbnail images by drag & drop?
The reason is that I need a thumbnail control that displays images (similar as e. g. Adobe reader displays the pages on the left side (screenshot), but the user should be able to sort these images by drag & drop.
Thanks in advance for any tips
Andreas
|
|
|
|
|
ab-tools wrote: is there any thumbnail control that supports the sorting of thumbnail images by drag & drop?
Yes and no. It's not a "thumbnail"-control, but the standard PictureBox does provide all the functionality you're after;
- Set the size and width of the desired thumbnail-image
- Set the SizeMode[^] to
StretchImage - Support for Drag and Drop[^]
--edit;
Sounds logical to have multiple of those in a Panel
I are Troll
|
|
|
|
|
Hello Eddy,
first thank you for your fast answer.
Yes, I already thought about doing that with PictureBoxes.
But it's not just the drag & drop of the PictureBoxes themselves, but also an additional label (e. g. for a file name or a page number) for each PictureBox and, of course, it also should look good: so the user can see which PictureBox is selected at the moment and also sees where he has to drop it for changing the sorting.
So I just hoped there exists already a control that does such things. Of course, I would also pay some money for it if I save the time implementing it by myself.
Best regards and thanks for any futher ideas on that topic
Andreas
|
|
|
|
|
ab-tools wrote: also an additional label (e. g. for a file name or a page number) for each PictureBox
Still thinking along the lines of the PictureBox, that would be done by overriding the Paint-handler, drawing the text onto the picture yourself.
ab-tools wrote: it also should look good: so the user can see which PictureBox is selected
"Pretty" is an opinion, I can't help there
The selection would be done by drawing a square around the box, in the current "selection" color as defined by the users' configuration.
ab-tools wrote: So I just hoped there exists already a control that does such things.
There's probably a lot that comes close, like the Tiles control from Infragistics[^].
I are Troll
|
|
|
|
|
Hello Eddy,
thanks again.
Then I'll do it on my own - just thought there would be a control that I can use out of the box...
Best regards
Andreas
|
|
|
|
|
Hi,
I am trying to make an application which tries to read the website ip's currentely visited. I have found an example of packet sniffer in c# (http://www.codeproject.com/KB/IP/CSNetworkSniffer.aspx).
My problem is that i dont want to run the call conitnuously. So i kept the call in a timer. All works fine, but when i plugged in my wifi internet connection( in addtion to my current lan connection), i was not able to view webpage. So i modified the code such a way to montior the ip through all the port. Then i am getting
System.Net.Sockets.SocketException: An invalid argument was supplied
at System.Net.Sockets.Socket.IOControl(Int32 ioControlCode, Byte[] optionInValue, Byte[] optionOutValue)
at System.Net.Sockets.Socket.IOControl(IOControlCode ioControlCode, Byte[] optionInValue, Byte[] optionOutValue) Here is my code
private void checkIP()
{
mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
mainSocket.Bind(new IPEndPoint(IPAddress.Any,0));
mainSocket.SetSocketOption(SocketOptionLevel.IP,
SocketOptionName.HeaderIncluded,
true);
byte[] byTrue = new byte[4] { 1, 0, 0, 0 };
byte[] byOut = new byte[4] { 1, 0, 0, 0 };
mainSocket.IOControl(IOControlCode.ReceiveAll,
byTrue,
byOut);
mainSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(OnReceive), null);
timer1Sec.Enabled = true;
}
private void OnReceive(IAsyncResult ar)
{
try
{
int nReceived = mainSocket.EndReceive(ar);
ParseData(byteData, nReceived);
}
catch (Exception ex)
{
}
} checkIP is called from a timer. I am getting exception in mainSocket.IOControl
|
|
|
|
|
hi guys.
Any one has idea about how can we give enum member like A+,B+...
public enum Color
{
Any,
D+,
D,
D-,
E+
};
I tried creating above enum but bad luck its giving error saying } expected.
dipak
|
|
|
|
|
You can't.
Enum members follow the normal rules for names - same as methods, properties, fields and namespaces.
All you can do is use the word "Plus" or "Minus" instead.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Does it mean that ther is no way to make such member in enum?
dipak
|
|
|
|
|
Yes.
In C#, all identfiers (methods, properties, fields, and namespaces) must adhere to the following rules:
The name can contain letters, digits, and the underscore character (_).
The first character of the name must be a letter. The underscore is also a legal first character, but its use is not recommended at the beginning of a name. An underscore is often used with special commands, and it's sometimes hard to read.
Case matters (that is, upper- and lowercase letters). C# is case-sensitive; thus, the names count and Count refer to two different variables.
C# keywords can't be used as variable names. Recall that a keyword is a word that is part of the C# language.
The characters '+', '-', '(' ')', '=', ',', ';' and many others cannot be used in the name of any identifier.
So, no. You can't do it. At all. Ever.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
You can only use underscores and alphnumeric characters in enum ordinal names. You also can't start the name with a digit.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Add a Description attribute, and use reflection to extract the description from that e.g
[Description("D+")]
DPlus There are numerous samples showing how to do this.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|