|
Hello,
Look up the contents of the System.Windows.Media.Imaging namespace, namely PixelFormat and FormatConvertedBitmap. That should get you started. You'll need references to System.Windows.Media.Imaging and WindowsBase.
|
|
|
|
|
The easiest way is to create a new 8 bit bitmap, and draw your 24 bit image onto it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
can you please help me to convert 8bpp avi files to 24 or 16 bpp without loss of proper colors in the matrix. I have to split avi file into bitmap images. The code works fine for 16 bpp or more but has a problem when you split 8bpp avi files. Please Help!
A Simple C# Wrapper for the AviFile Library[^]
Thanks in Advance!
|
|
|
|
|
Hello every one
I am using DataGridView in my VB2005 Express application, I have following issues
- How can I restrict the maximum size of text entered by the user in a particular cell
- The second (requires a bit lengthy description sorry for that)
o After the grid is created the user can click on the cell header to align the rows in ascending or descending order.
o Now if I have a grid with 10 rows(say) and have data only in 2 and the user clicks the cell header then the blank rows come at the top of the grid
o How can I make it sure that when the column header is clicked the blank rows stay at the bottom only i.e. only the rows with data are sorted
- This one is related with previous issue : Can I some how make it sure that one row with data can also be not included in the sorted alignment, i.e. the row acts like a non moving row at that place only
- Is there any property by which I can even disable that sorting feature??
Regards
Nishkarsh
|
|
|
|
|
1 - if you're creating a textbox, you can specify in it's properties the maximum length
2 - You should not have 'blank rows' at all, this is a problem with your overall design. You should have an option to create a new row if a user is entering a new row, not have 8 empty rows there
3 - you have to write your own sorting algorithm and make it work in the manner you're describing.
4 - yes, you can turn off sorting
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for the reply
Christian Graus wrote: 2 - You should not have 'blank rows' at all, this is a problem with your overall design. You should have an option to create a new row if a user is entering a new row, not have 8 empty rows there
this is a Look and feel issue and i can not help it... ppl hear feel that showing blank grid back dose not look good
Christian Graus wrote: 3 - you have to write your own sorting algorithm and make it work in the manner you're describing.
Christian Graus wrote: 4 - yes, you can turn off sorting
How do i do it?
|
|
|
|
|
nishkarsh_k wrote: this is a Look and feel issue and i can not help it... ppl hear feel that showing blank grid back dose not look good
Well, if you have blank rows inserted, they exist and will be sorted, not much you can do, unless you write a custom sort.
http://msdn2.microsoft.com/en-us/library/ms171607.aspx[^]
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello There
I have tried very much but could not work around it. The problem is that i want to disable the web browser control's context menu and the shortcut keys, for example pressing the Cntr+N will open a new internet explorer window.
Does anyone know how do I disable the context menu and shortcut keys of the VB6 web browser control?
Regards,
Sarfraz
|
|
|
|
|
Hi Friends..
I want to install my VB.Net appication through the set-up created.
But the thing is i need the exe automatically run after the setup is installed(i.e without clicking the shortcut made..).HOw to do it..?Is there any possiblity to fdo so..
Someone help in this regard ..
Thx in Advance..
Balaguru
|
|
|
|
|
You can force your app to run on reboot by putting it in the run ( to run every time ) or runonce ( to just run once ) key in the registry. Or you can add a shortcut to it in the startup folder of the start menu.
You can also set up your MSI so it shows the option to run the app at the end of the install.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Dear Graus..
Thanks for the reply..But i am not aware of doing it.Can u just guide me with the steps to make my app run in either ways as precribed by you.?
Thanks in Advance..
Balaguru
|
|
|
|
|
I'm not really sure what to say. If you're building an installer, then your installer needs to create those registry keys. I don't know what installer you're using, surely you're capable of reading it's documentation ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Dear Graus..
My application is in VB.Net and i have created the set-up and now i need to deploy the setup..Morover you were saying about documentation..What do u mean..I can't understand..
Thanks & Regards,
Balaguru
|
|
|
|
|
Well, how did you create the setup ? Obviously, the setup is what needs to set up the PC to run your program, right ? Your code isn't magically going to run itself. For example, I use Advanced Installer to create the setup, and it has options to create registry keys as part of the install.
I'm sorry, this is so simple, that I really don't know what else I can say.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am new to .Net. and I am sorry for my bad english.
Below is my code to encrypting and decrypting the image by using DES algorithm. but I am getting an exception please any body can help me in this issue.Please very urgent
exception like "Parameter is not valid."
Imports System
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Imports System.Collections.Generic
Imports System.Drawing
Public Class Encrypt
Dim passPhrase As String = "water"
Dim saltValue As String = "EncryptionAndDecryption"
Dim hashAlgorithm As String = "SHA1"
Dim passwordIterations As Integer = 1
Dim initVector As String = "@1B2c3D4e5F6g7H8"
Dim keySize As Integer = 256
Public Function Encrypt(ByVal imagepath As String) As String
Dim initVectorBytes As Byte() = Encoding.ASCII.GetBytes(initVector)
Dim saltValueBytes As Byte() = Encoding.ASCII.GetBytes(saltValue)
Dim imageIn As System.Drawing.Image
imageIn = Drawing.Image.FromFile(imagepath)
Dim ms As New MemoryStream()
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim plainTextBytes As Byte() = ms.ToArray()
'Dim fs As FileStream = New FileStream(imagepath, FileMode.Open, FileAccess.Read)
'Dim plainTextBytes As Byte() = New Byte(fs.Length) {}
Dim password As PasswordDeriveBytes = New PasswordDeriveBytes(passPhrase, saltValueBytes, hashAlgorithm, passwordIterations)
Dim keyBytes As Byte() = password.GetBytes(keySize / 8)
Dim symmetricKey As RijndaelManaged = New RijndaelManaged()
symmetricKey.Mode = CipherMode.CBC
Dim encryptor As ICryptoTransform = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes)
Dim memoryStream As MemoryStream = New MemoryStream()
Dim cryptoStream As CryptoStream = New CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length)
cryptoStream.FlushFinalBlock()
Dim cipherTextBytes As Byte() = memoryStream.ToArray()
memoryStream.Close()
cryptoStream.Close()
Dim cipherText As String = Convert.ToBase64String(cipherTextBytes)
Return cipherText
End Function
Public Function Decrypt(ByVal cipherText As String) As String
Dim initVectorBytes As Byte() = Encoding.ASCII.GetBytes(initVector)
Dim saltValueBytes As Byte() = Encoding.ASCII.GetBytes(saltValue)
Dim cipherTextBytes As Byte() = Convert.FromBase64String(cipherText)
Dim password As PasswordDeriveBytes = New PasswordDeriveBytes(passPhrase, saltValueBytes, hashAlgorithm, passwordIterations)
Dim keyBytes As Byte() = password.GetBytes(keySize / 8)
Dim symmetricKey As RijndaelManaged = New RijndaelManaged()
symmetricKey.Mode = CipherMode.CBC
Dim decryptor As ICryptoTransform = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes)
Dim memoryStream As MemoryStream = New MemoryStream(cipherTextBytes)
Dim cryptoStream As CryptoStream = New CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)
Dim plainTextBytes As Byte() = New Byte(cipherTextBytes.Length) {}
Dim decryptedByteCount As Integer = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length)
'memoryStream.Close()
'cryptoStream.Close()
Dim plaintext As String = Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount)
Dim count() As Byte = New Byte(decryptedByteCount) {}
Dim img As System.Drawing.Image
Dim stream As New MemoryStream(count, 0, count.Length)
stream.Write(count, 0, count.Length)
' img = New Bitmap(stream)
'img.Save("C:\test.bmp")
'Dim myimage As New System.Drawing.Bitmap(stream)
img = Image.FromStream(stream, True) // getting exception here like "Parameter is not valid" 'myimage.Save("C:\test.bmp")
img.Save("C:\test.bmp")
memoryStream.Close()
cryptoStream.Close()
'Dim bitImage As Bitmap = New Bitmap(System.Drawing.Image.FromStream(stream))
'bitImage.Save("C:\test.bmp")
' Dim memStream As MemoryStream = New MemoryStream(2388139)
' Dim bitImage As Bitmap = New Bitmap(System.Drawing.Image.FromStream(memStream))
' bitImage.Save( ("C:\test.bmp")
Return plaintext
End Function
End Class
in module I have this code.
Imports System
Imports System.IO
Imports System.Security
Imports System.Security.Cryptography
Imports System.Runtime.InteropServices
Imports System.Text
Module Module1
' Call this function to remove the key from memory after it is used for security.
<DllImport("kernel32.dll")> _
Public Sub ZeroMemory(ByVal addr As IntPtr, ByVal size As Integer)
End Sub
' Function to generate a 64-bit key.
Function GenerateKey() As String
' Create an instance of a symmetric algorithm. The key and the IV are generated automatically.
Dim desCrypto As DESCryptoServiceProvider = DESCryptoServiceProvider.Create()
' Use the automatically generated key for encryption.
Return ASCIIEncoding.ASCII.GetString(desCrypto.Key)
End Function
Sub EncryptFile(ByVal sInputFilename As String, _
ByVal sOutputFilename As String, _
ByVal sKey As String)
Dim fsInput As New FileStream(sInputFilename, _
FileMode.Open, FileAccess.Read)
Dim fsEncrypted As New FileStream(sOutputFilename, _
FileMode.Create, FileAccess.Write)
Dim DES As New DESCryptoServiceProvider()
'Set secret key for DES algorithm.
'A 64-bit key and an IV are required for this provider.
DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey)
'Set the initialization vector.
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey)
'Create the DES encryptor from this instance.
Dim desencrypt As ICryptoTransform = DES.CreateEncryptor()
'Create the crypto stream that transforms the file stream by using DES encryption.
Dim cryptostream As New CryptoStream(fsEncrypted, _
desencrypt, _
CryptoStreamMode.Write)
'Read the file text to the byte array.
Dim bytearrayinput(fsInput.Length - 1) As Byte
fsInput.Read(bytearrayinput, 0, bytearrayinput.Length)
'Write out the DES encrypted file.
cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length)
cryptostream.Close()
End Sub
Sub DecryptFile(ByVal sInputFilename As String, _
ByVal sOutputFilename As String, _
ByVal sKey As String)
Dim DES As New DESCryptoServiceProvider()
'A 64-bit key and an IV are required for this provider.
'Set the secret key for the DES algorithm.
Console.WriteLine(sKey)
DES.Key() = ASCIIEncoding.ASCII.GetBytes(sKey)
'Set the initialization vector.
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey)
'Create the file stream to read the encrypted file back.
'Dim fsread As New FileStream(sInputFilename, FileMode.Open, FileAccess.Read)
Dim fsread As New FileStream(sInputFilename, FileMode.Open, FileAccess.Read)
'Create the DES decryptor from the DES instance.
Dim desdecrypt As ICryptoTransform = DES.CreateDecryptor()
'Create the crypto stream set to read and to do a DES decryption transform on incoming bytes.
Dim cryptostreamDecr As New CryptoStream(fsread, desdecrypt, CryptoStreamMode.Read)
'Print out the contents of the decrypted file.
Dim fsDecrypted As New StreamWriter(sOutputFilename)
fsDecrypted.Write(New StreamReader(cryptostreamDecr).ReadToEnd)
fsDecrypted.Flush()
fsDecrypted.Close()
End Sub
Public Sub Main()
Dim obj As Encrypt = New Encrypt()
Dim image As Image
'image = Drawing.Image.FromFile("C:\Documents and Settings\lakshmi\Desktop\lakshmi\008 (2).JPG")
Dim ar As String = obj.Encrypt("C:\Documents and Settings\sudhakar\My Documents\My Pictures\last5minutesofexam.bmp")
Dim str As String = obj.Decrypt(ar)
'Must be 64 bits, 8 bytes.
Dim sSecretKey As String
' Get the key for the file to encrypt.
' You can distribute this key to the user who will decrypt the file.
sSecretKey = GenerateKey()
'sSecretKey = "@fffe7e95"
' For additional security, pin the key.
Dim gch As GCHandle = GCHandle.Alloc(sSecretKey, GCHandleType.Pinned)
' Encrypt the file.
'EncryptFile("D:\Inbox path laxmi.txt", _
' "D:\Encrypted.txt", _
' sSecretKey)
'' Decrypt the file.
'DecryptFile("D:\Encrypted.txt", _
' "D:\Decrypted.txt", _
' sSecretKey)
' Remove the key from memory.
ZeroMemory(gch.AddrOfPinnedObject(), sSecretKey.Length * 2)
gch.Free()
End Sub
End Module
Thanks and Regards,
sudhakar venati,
Mob: 0 984 55 989 71.
|
|
|
|
|
looks to me like the stream is not valid, therefore I assume your decryption is not happening.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Friend
i am using Split Container in windows application. It work properly. but when i drag split then focus not leave the splitter then how i can leave the focus after the drag. Please Help me
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
|
|
|
|
|
Please don't spam the whole site.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i want to create excel graph through .net then which component is use for accessing the excel application . i have ready program for creating excel graph thro' .net only required component ...............plz suggest me.....
modified on Tuesday, February 12, 2008 2:34 AM
|
|
|
|
|
Hi,
In regards to your question I would like to mention that to access the MS Office application (components) you need to have VSTO 2005 (Visual Studio 2005 Tools for Office Second Edition) The Second Addition empowers developers to develop application targeting Office 2007 applications.
If you have VSTO patches installed on your machine then you need to use
Microsoft.VisualStudio.Tools.Office.Excel.dll in your application.
For more information regarding the VSTO components please visit the following link: http://blogs.msdn.com/vsto2/
I hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
I'm new in VB.Net.
I want to generate document number in this format <yyyymmdd><custid><running_no>
i cannot make the date format starting with year so i make 3 text box each is year, month n day. how to make 3 items from date, custID and running_no put in one field call docNo.
i'm using Microsoft Visual Studio .NET
|
|
|
|
|
zaimah wrote: i cannot make the date format starting with year
The way to do this is the overload of the ToString method that lets you specify the format with a format string like YYYYMMDD.
zaimah wrote: how to make 3 items from date, custID and running_no put in one field call docNo.
Assuming the are all textboxes
docNo.Text = date.Text + custID.Text + running_no.Text
zaimah wrote: i'm using Microsoft Visual Studio .NET
Well, obviously. Telling us the version number may help, but we know you're using visual studio.
I suspect you'd benefit from working through a book on VB.NET, it would cover things like how ToString is overloaded, and how to add strings to each other.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks a lot for ur reply. It really help me a lot.
|
|
|
|
|
hi, i have used the formula that u gave. it works, but there's one problem. i use docNo = System.DateTime.Now.ToString("yyyyMMdd") + Kod.Text + (values from field 'run_no' from 'table runNo')
how to add values from other table?
|
|
|
|
|
Hi, i m developing a text editor in vb.net. i m using webbrowser control for text editing. All i want is
when user press Crtl+S during writing the text it write letter 's' in text editing area. How can i avoid this ???? Thx in advance
i look in KeyPreviewEvent of webbrowser, but like vb i didn't see any property to replace the incoming keycode (e.keycode is readonly) with zero or nothing to prevent writing the letter 's'
King
|
|
|
|