Click here to Skip to main content
15,889,909 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Oracle stored procedures with VB.net Pin
Larry Gaukel23-May-07 9:46
Larry Gaukel23-May-07 9:46 
Questionmultiline ListView vb.net 2005 Pin
Allwin0718-May-07 7:33
Allwin0718-May-07 7:33 
AnswerRe: multiline ListView vb.net 2005 Pin
Dave Kreskowiak18-May-07 9:56
mveDave Kreskowiak18-May-07 9:56 
Questioncaret line number (not the "just" line number ) Pin
NANCO18-May-07 5:48
NANCO18-May-07 5:48 
AnswerRe: caret line number (not the "just" line number ) Pin
Dave Kreskowiak18-May-07 6:36
mveDave Kreskowiak18-May-07 6:36 
GeneralRe: caret line number (not the "just" line number ) Pin
NANCO19-May-07 1:08
NANCO19-May-07 1:08 
GeneralRe: caret line number (not the "just" line number ) Pin
Dave Kreskowiak19-May-07 4:06
mveDave Kreskowiak19-May-07 4:06 
QuestionConvert image from 24bpp to 1bppindexed Pin
stuinstra35118-May-07 5:42
stuinstra35118-May-07 5:42 
I'm having trouble with some code to convert a 24bpp image to a 1bppindex image. I get an exception when I do a Marshal.copy of the destinationBuffer back to the 1bpp image. The exception message is: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
If my destination bitmap is an 8bppindex image or higher (ie. 24rgbbpp) the problem doesn't occur.

Public Function ConvertToBitonalNew(ByVal original As Bitmap) As Bitmap
Dim source As Bitmap
source = original
Dim rect As New Rectangle(0, 0, source.Width, source.Height)
Dim bmpData As BitmapData = source.LockBits(rect, ImageLockMode.ReadWrite, source.PixelFormat)
Dim ptr As IntPtr = bmpData.Scan0
Dim imageSize As Integer = source.Width * source.Height * 3
Dim sourceBuffer(imageSize - 1) As Byte
Marshal.Copy(ptr, sourceBuffer, 0, imageSize)
source.UnlockBits(bmpData)

Dim destBmp As Bitmap = New Bitmap(source.Width, source.Height, PixelFormat.Format1bppIndexed)
destBmp.SetResolution(source.HorizontalResolution, source.VerticalResolution)
Dim destData As BitmapData = destBmp.LockBits(New Rectangle(0, 0, destBmp.Width, destBmp.Height), ImageLockMode.ReadWrite, destBmp.PixelFormat)
Dim ptrDest As IntPtr = destData.Scan0
imageSize = destBmp.Width * destBmp.Height
Dim destBuffer(imageSize) As Byte
Dim y As Integer = 1
For x As Integer = 2 To sourceBuffer.Length - 1 Step 3
If sourceBuffer(x) > 128 Then
destBuffer(y) = CByte(1)
Else
destBuffer(y) = CByte(0)
End If
y = y + 1
Next x
'the line below throws an exception
Marshal.Copy(destBuffer, 0, ptrDest, destBmp.Width * destBmp.Height)
destBmp.UnlockBits(destData)
source.Dispose()
Return destBmp
End Function
End Class


Steve T.
AnswerRe: Convert image from 24bpp to 1bppindexed Pin
Dave Kreskowiak18-May-07 6:25
mveDave Kreskowiak18-May-07 6:25 
AnswerRe: Problem Fixed Pin
stuinstra35118-May-07 7:44
stuinstra35118-May-07 7:44 
Questioncheck database for fields Pin
jds120718-May-07 4:40
jds120718-May-07 4:40 
QuestionDataGridView databound to textboxes and CellValidating Pin
Marcus J. Smith18-May-07 4:00
professionalMarcus J. Smith18-May-07 4:00 
AnswerRe: DataGridView databound to textboxes and CellValidating Pin
kubben18-May-07 5:52
kubben18-May-07 5:52 
GeneralRe: DataGridView databound to textboxes and CellValidating Pin
Marcus J. Smith18-May-07 7:24
professionalMarcus J. Smith18-May-07 7:24 
GeneralRe: DataGridView databound to textboxes and CellValidating Pin
kubben18-May-07 7:30
kubben18-May-07 7:30 
GeneralRe: DataGridView databound to textboxes and CellValidating Pin
Marcus J. Smith18-May-07 7:46
professionalMarcus J. Smith18-May-07 7:46 
GeneralRe: DataGridView databound to textboxes and CellValidating Pin
kubben18-May-07 7:48
kubben18-May-07 7:48 
GeneralRe: DataGridView databound to textboxes and CellValidating Pin
Marcus J. Smith18-May-07 8:20
professionalMarcus J. Smith18-May-07 8:20 
GeneralRe: DataGridView databound to textboxes and CellValidating Pin
kubben18-May-07 8:24
kubben18-May-07 8:24 
GeneralRe: DataGridView databound to textboxes and CellValidating Pin
Marcus J. Smith18-May-07 8:43
professionalMarcus J. Smith18-May-07 8:43 
QuestionChat Application Pin
kantipudi18-May-07 3:45
kantipudi18-May-07 3:45 
AnswerRe: Chat Application Pin
Dave Kreskowiak18-May-07 4:24
mveDave Kreskowiak18-May-07 4:24 
GeneralRe: Chat Application Pin
Paul Conrad18-May-07 6:16
professionalPaul Conrad18-May-07 6:16 
GeneralRe: Chat Application Pin
leckey18-May-07 8:01
leckey18-May-07 8:01 
GeneralRe: Chat Application Pin
Paul Conrad18-May-07 10:18
professionalPaul Conrad18-May-07 10:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.