我想了解如何使用FJCore將WriteableBitmap編碼爲jpeg。我知道WriteableBitmap提供了原始像素,但我不確定如何將其轉換爲FJCore對其JpegEncoder方法的預期格式。 JpegEncoder有兩個重載,一個需要一個FluxJpeg.Core.Image,另一個需要一個DecodedJpeg。使用FJCore編碼Silverlight WriteableBitmap
我試圖創建一個FluxJpeg.Core.Image,但它需要一個字節[] [,]作爲圖像數據。 byte [n] [x,y]其中x是寬度,y是高度,但我不知道應該是什麼n。
我認爲n應該是4,因爲那將對應於在每個像素中編碼的argb信息,但是當我嘗試FJCore拋出一個參數超出範圍異常。這是我試過的。柵格是我的byte [4] [x,y]數組。
raster[0][x, y] = (byte)((pixel >> 24) & 0xFF);
raster[1][x, y] = (byte)((pixel >> 16) & 0xFF);
raster[2][x, y] = (byte)((pixel >> 8) & 0xFF);
raster[3][x, y] = (byte)(pixel & 0xFF);
希望你不介意,但我用你的代碼並將其擴展爲完整的文章,請參閱:http://blog.blueboxes.co.uk/2009/07/21/rendering-xaml-to-a-jpeg-using-silverlight-3/,並將您正確歸因於根據CC許可證 – John 2009-07-21 19:53:32