Results 1 to 10 of 96
Threaded View
-
9th Jan 2010, 05:43 AM #11OPRespected Developer
Finally cracked it, the fasted encoding speed the above methods gave me was 650 Kbyte/sec. I switched to FastPixel for the drawing and added functions to FastPixel to be able to draw pixels via bytes instead of passing Color objects. Also changed to staged caching. New encoding speed: 2-3 Mbyte/sec. That is faster than the speed I get in the winrar bechmark so should be a fast enough starting point for peoples.
The magic, for those interested:
Code:let CreateImages file = let fileInfo = new FileInfo(file) let fileName = DoCorrectFileName fileInfo let numOfImgs = CalcNumOfImgsRequired (int fileInfo.Length) (CalcImgBytes DefaultImgRes.X DefaultImgRes.Y 3) [for i in [ 0 .. numOfImgs - 1 ] -> async { let header = CreateHeader (i+1) numOfImgs FileVersion fileName use fs = fileInfo.OpenRead() use bmp = new Bitmap(DefaultImgRes.X, DefaultImgRes.Y, PixelFormat.Format32bppArgb) let fpx = new FastPixel(bmp) fs.Position <- int64 ((((DefaultImgRes.X * DefaultImgRes.Y) - header.Length) * 3) * i) let length = ((DefaultImgRes.X * DefaultImgRes.Y) - header.Length) * 3 let count = ref 0 let buffer' = ref (Array.create (length + 1) 0x00uy) let GetX y = if (y = 0) then header.Length - 1 else 0 let realLength = fs.Read(!buffer', 0, (!buffer').Length) let buffer = (!buffer').[0 .. realLength - 1] |> Seq.ofArray |> Break 3 |> Array.ofSeq // Set file stream offset and free temp buffer buffer' := Array.empty<byte> fpx.Lock() // Write header for x in [ 0 .. header.Length - 1 ] do fpx.SetPixel(x, 0, header.[x]) // Bytes to pixels for y in [ 0 .. DefaultImgRes.Y - 1 ] do for x in [ GetX y .. DefaultImgRes.X - 1 ] do if (!count < buffer.Length) then match (buffer.[!count].Length) with | 3 -> fpx.SetBytes(x, y, byte AlphaFlags.ALL, buffer.[!count].[0], buffer.[!count].[1], buffer.[!count].[2]) | 2 -> fpx.SetBytes(x, y, byte AlphaFlags.RG, buffer.[!count].[0], buffer.[!count].[1], 0x00uy) | 1 -> fpx.SetBytes(x, y, byte AlphaFlags.R, buffer.[!count].[0], 0x00uy, 0x00uy) | _ -> fpx.SetBytes(x, y, byte AlphaFlags.END, 0x00uy, 0x00uy, 0x00uy) count := !count + 1 else fpx.SetBytes(x, y, byte AlphaFlags.END, 0x00uy, 0x00uy, 0x00uy) fpx.Unlock(true) return bmp}] |> Async.Parallel |> Async.RunSynchronously
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 3 users browsing this thread. (0 members and 3 guests)
Similar Threads
-
Random Text & Images In Signatures
By zac2613 in forum phpBBReplies: 0Last Post: 10th Jan 2012, 06:36 AM -
How to recover deleted or lost data, file, photo on Mac with Data Recovery software
By Jack20126 in forum General DiscussionReplies: 0Last Post: 20th Dec 2011, 03:37 AM -
Random.org generated massive data
By BlaZe in forum News & Current EventsReplies: 3Last Post: 8th Jul 2011, 06:50 AM -
Random Funny Images!
By xfernanx in forum General DiscussionReplies: 1Last Post: 28th Oct 2010, 04:31 AM
themaCreator - create posts from...
Version 3.57 released. Open older version (or...