Click here to Skip to main content
15,906,569 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionInserting a row using datagridview Pin
projectcode17-Apr-06 10:22
projectcode17-Apr-06 10:22 
QuestionCopyMemory VB.NET Pin
chiragdanech7-Apr-06 9:26
chiragdanech7-Apr-06 9:26 
AnswerRe: CopyMemory VB.NET Pin
Joshua Quick7-Apr-06 12:07
Joshua Quick7-Apr-06 12:07 
GeneralRe: CopyMemory VB.NET Pin
chiragdanech8-Apr-06 7:14
chiragdanech8-Apr-06 7:14 
AnswerRe: CopyMemory VB.NET Pin
Joshua Quick8-Apr-06 9:18
Joshua Quick8-Apr-06 9:18 
GeneralRe: CopyMemory VB.NET Pin
chiragdanech8-Apr-06 9:22
chiragdanech8-Apr-06 9:22 
QuestionRe: CopyMemory VB.NET Pin
Joshua Quick8-Apr-06 9:41
Joshua Quick8-Apr-06 9:41 
AnswerRe: CopyMemory VB.NET Pin
chiragdanech8-Apr-06 9:47
chiragdanech8-Apr-06 9:47 
Public Function LongPixels() As Long()
'_____________________________________________________
'
' Purpose: converts the 2-dimensional 3/4 Byte DIB into a one-
' dimensional Long array, for easy summing of long int values.
' scans from left to right, then bottom to top.
' diblongarray(0) = lower left pixel.
' diblongarray(ubound) = upper right pixel.
' Assumptions: the DIB is 24-bit, the byte order of the pixels is
' r-g-b (not the common b-g-r)
' Affects:
' Inputs:
' Returns:
'_____________________________________________________

Dim bDibMag() As Byte '2 dimensional byte array holds pixels by row,col
Dim lX As Long, lY As Long 'x = pixel col, y = pixel row
Dim saDibMag As SAFEARRAY2D
Dim lXEnd As Long
Dim l As Long
Dim lCol As Long

On Error GoTo Cleanup

'structure the 2-dimensional safearray
With saDibMag
.cbElements = 1 'bytes to an element
.cDims = 2 'dimensions
.Bounds(0).lLbound = 0 'lbound of 1st dim
.Bounds(0).cElements = Height '# rows = height in pixels
.Bounds(1).lLbound = 0 'lbound of 2nd dim
.Bounds(1).cElements = LineByteWidth() 'calculate width with 24/32 row pad
.pvData = lPtrDibMag 'pointer to the DIBits
End With

'HH: MoveMemory is not available in Windows API but in Win32 API, similar command in current API is CopyMemory
'for MoveMemory, it's definition: Sub MoveMemory(pDest As Any, pSource As Any, ByteLen As Long)
'it moves a block of memory from one location to another.
'VarPtr: retrieves the memory handle of an object.
'ATTN: while calling using ByVal, it transfer the the source's memory handle
'if calling byRef(default), it instead transfer the tempoary variable that stores the souce's memory handle
'in a simple way, the following command is a quicker way, if there's a bunch of data, to pass values
'of source variable to destination variable

MoveMemory ByVal VarPtrArray(bDibMag()), VarPtr(saDibMag), 4 'copy safe array to bDibMag

lXEnd = (Width - 1) * 3
l = 0

ReDim lColor(Width * Height - 1) '4 MB
'HH: FOLLWING LOOP READS TWO DIMENSIONAL VALUE AND STORE THEM INTO A ONE-DIMENSION LONG ARRAY
'HH: READS VALUE FROM BOTTOM TO TOP
For lY = 0 To biDibMag.bmiHeader.biHeight - 1
DoEvents
'HH: FOR EACH ROW, READS VALUE FROM LEFT TO RIGHT
For lX = 0 To lXEnd Step 3
MoveMemory lCol, bDibMag(lX, lY), 3
lColor(l) = lCol
lCol = 0
MoveMemory ByVal VarPtr(lCol), 0&, 3
l = l + 1
Next lX
Next lY

LongPixels = lColor

lPix = l 'store pixelcount

'zero out the moved memory, so as to avoid
'a pacman-like memory-use situation
MoveMemory ByVal VarPtrArray(bDibMag), 0&, 4

Cleanup:

Erase saDibMag.Bounds
Erase lColor
Erase bDibMag

If err.Number <> 0 Then WriteLog "MAGRAS ERROR In Procedure LongPixels, #" _
& err.Number & ": " & err.Description

err.Clear

End Function

this is the VB function which i need to convert to VB.NET...this is the way i have defined the two dimensional array in VB.NET project..

Dim bDibMag(,) As Long '2 dimensional byte array holds pixels by row,col

Thanks again for taking interest in this problem..






Chirag...
chirag.danech@gmail.com
GeneralRe: CopyMemory VB.NET Pin
Joshua Quick9-Apr-06 10:49
Joshua Quick9-Apr-06 10:49 
GeneralRe: CopyMemory VB.NET Pin
chiragdanech9-Apr-06 10:55
chiragdanech9-Apr-06 10:55 
AnswerRe: CopyMemory VB.NET Pin
Joshua Quick9-Apr-06 12:12
Joshua Quick9-Apr-06 12:12 
QuestionPDF to printdocument Pin
aWaLsH5237-Apr-06 5:51
aWaLsH5237-Apr-06 5:51 
QuestionWindows Service Not in the list Pin
Brent Lamborn7-Apr-06 5:35
Brent Lamborn7-Apr-06 5:35 
AnswerRe: Windows Service Not in the list Pin
Purple Monk7-Apr-06 5:50
Purple Monk7-Apr-06 5:50 
GeneralRe: Windows Service Not in the list Pin
Brent Lamborn7-Apr-06 9:22
Brent Lamborn7-Apr-06 9:22 
QuestionProblem with form loading Pin
wliong7-Apr-06 5:34
wliong7-Apr-06 5:34 
AnswerRe: Problem with form loading Pin
Purple Monk7-Apr-06 5:55
Purple Monk7-Apr-06 5:55 
GeneralRe: Problem with form loading Pin
wliong7-Apr-06 6:41
wliong7-Apr-06 6:41 
Questionconverting a report to PDF and saving it(in VB 6.0) Pin
dex58ter7-Apr-06 4:10
dex58ter7-Apr-06 4:10 
AnswerRe: converting a report to PDF and saving it(in VB 6.0) Pin
Vikrant Badhai7-Apr-06 23:38
Vikrant Badhai7-Apr-06 23:38 
QuestionPrintPreviewDialog Class - Default Title Pin
paas7-Apr-06 3:45
paas7-Apr-06 3:45 
AnswerRe: PrintPreviewDialog Class - Default Title Pin
paas7-Apr-06 9:43
paas7-Apr-06 9:43 
Questioni have seriously problem with vb.net (hook) Pin
bkarasa7-Apr-06 2:09
bkarasa7-Apr-06 2:09 
AnswerRe: i have seriously problem with vb.net (hook) Pin
Purple Monk7-Apr-06 2:20
Purple Monk7-Apr-06 2:20 
GeneralRe: i have seriously problem with vb.net (hook) Pin
bkarasa7-Apr-06 3:07
bkarasa7-Apr-06 3:07 

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.