|
-
Nov 11th, 2005, 04:33 PM
#1
Thread Starter
New Member
JPEG RLE / Algorythm
Hi all,
I'm reasonably new to programming and am attempting a reasonably ambitious project: streaming video between 2 apps over the web.
The video is being captured at runtime with a web cam and what I intend to do is send the frames as jpegs. However, the only method I have managed to get to work so far is to save each frame to disk as jpeg and then read it from the disk. The only problem with this is that it is going to kill the hard disks. (and is slower)
So what I was hoping to do is compress the images in an imageList using run length encoding similar to that of JPEG compression. My only problem is that I am not sure of the algorythm to compress my images in that way.
Can somebody please point me in the right direction?
Am I barking up the wrong tree?
Ive tried changing the colour depth of the imageList but it hasnt made any considerable changes to the fiel size. Ive also thought about changing the images to thumbnails but it appears that this can increase the file size.
Any help would be extremely appreciated.
Thansk heaps.
Glytch.
-
Nov 11th, 2005, 04:42 PM
#2
Re: JPEG RLE / Algorythm
Hmm.. not sure what you are needing.. but this is the code I use in order save a JPEG at various compression qualities...
VB Code:
'Sub Declaration
Public Shared Sub SaveJpeg(ByVal path As String, ByVal img As Image, ByVal quality As Long)
If ((quality < 0) OrElse (quality > 100)) Then
Throw New ArgumentOutOfRangeException("quality must be between 0 and 100.")
End If
' Encoder parameter for image quality
Dim qualityParam As New EncoderParameter(Encoder.Quality, quality)
' Jpeg image codec
Dim jpegCodec As ImageCodecInfo = GetEncoderInfo("image/jpeg")
Dim encoderParams As New EncoderParameters(1)
encoderParams.Param(0) = qualityParam
img.Save(path, jpegCodec, encoderParams)
End Sub
'Function Declaration used in Sub
Private Shared Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo
' Get image codecs for all image formats
Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders()
' Find the correct image codec
Dim i As Integer
For i = 0 To codecs.Length - 1
If (codecs(i).MimeType = mimeType) Then
Return codecs(i)
End If
Next i
Return Nothing
End Function
'and to call it in your code...
SaveJpeg("FullPathAndNameOfImage", ImageObject, 50) '50% compression quality
-
Nov 11th, 2005, 04:58 PM
#3
Thread Starter
New Member
Re: JPEG RLE / Algorythm
Thanks for the help gigemboy but thats not what I am after.
The code you have shown has to write the image to disk.
I want to compress the image whilst its still in RAM.
So far the only way I can see of doing this is to convert the image into a byte array and use run length encoding similar to jpeg compression.
Looking around the forum Ive seen that other people have wanted to do similar things. A common answer seems to be to use IJL.dll which is no longer available.
Suggestions? any more for any more?
-
Nov 12th, 2005, 09:30 AM
#4
Thread Starter
New Member
Re: JPEG RLE / Algorythm
I download Intels new replacement of the IJL.dll
cant make sense of it.
Can anybody point me to a book or anything that might help?
Also, does anybody know of a good tcp socket tutorial for vb.net?
thanks again.
Glytch.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|