Results 1 to 4 of 4

Thread: JPEG RLE / Algorythm

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    3

    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.

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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:
    1. 'Sub Declaration
    2. Public Shared Sub SaveJpeg(ByVal path As String, ByVal img As Image, ByVal quality As Long)
    3.         If ((quality < 0) OrElse (quality > 100)) Then
    4.             Throw New ArgumentOutOfRangeException("quality must be between 0 and 100.")
    5.         End If
    6.  
    7.         ' Encoder parameter for image quality
    8.         Dim qualityParam As New EncoderParameter(Encoder.Quality, quality)
    9.         ' Jpeg image codec
    10.         Dim jpegCodec As ImageCodecInfo = GetEncoderInfo("image/jpeg")
    11.  
    12.         Dim encoderParams As New EncoderParameters(1)
    13.         encoderParams.Param(0) = qualityParam
    14.         img.Save(path, jpegCodec, encoderParams)
    15. End Sub
    16. 'Function Declaration used in Sub
    17. Private Shared Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo
    18.         ' Get image codecs for all image formats
    19.         Dim codecs As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders()
    20.  
    21.         ' Find the correct image codec
    22.         Dim i As Integer
    23.         For i = 0 To codecs.Length - 1
    24.             If (codecs(i).MimeType = mimeType) Then
    25.                 Return codecs(i)
    26.             End If
    27.         Next i
    28.  
    29.         Return Nothing
    30. End Function
    31.  
    32. 'and to call it in your code...
    33. SaveJpeg("FullPathAndNameOfImage", ImageObject, 50) '50% compression quality

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    3

    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?

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    3

    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
  •  



Click Here to Expand Forum to Full Width