<p>Can anyone advise on how to crop an image, let's say jpeg, without using any .NET framework constructs, just raw bytes?  Since this is the only* way in Silverlight...</p>

<p>Or point to a library?</p>

<p>I'm not concerned with rendering i'm wanting to manipulate a jpg before uploading.</p>

<p>*There are no GDI+(System.Drawing) or WPF(System.Windows.Media.Imaging) libraries available in Silverlight.</p>

<p>Lockbits requires GDI+, clarified question</p>

<p>Using fjcore: <a href="http://code.google.com/p/fjcore/" rel="nofollow noreferrer">http://code.google.com/p/fjcore/</a> to resize but no way to crop :(</p>

[{'answer_id': 37052, 'author': 'Shog9', 'author_id': 811, 'author_profile': 'https://Stackoverflow.com/users/811', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://www.imagemagick.org/script/index.php" rel="nofollow noreferrer">ImageMagick</a> does a pretty good job. If you\'re ok with handing off editing tasks to your server...</p>\n\n<p>(Seriously? The recommended way of manipulating images in Silverlight is to work with <em>raw bytes</em>? That\'s... incredibly lame.)</p>\n'}, {'answer_id': 37075, 'author': 'neslekkiM', 'author_id': 3308, 'author_profile': 'https://Stackoverflow.com/users/3308', 'pm_score': 0, 'selected': False, 'text': '<p>where is silverlight executed?\nIs there any reason at all to send an complete picture to the client to make the client crop it?\nDo it on the server... (if you are not creating an image editor that is..)</p>\n'}, {'answer_id': 40725, 'author': 'Brian Leahy', 'author_id': 580, 'author_profile': 'https://Stackoverflow.com/users/580', 'pm_score': 2, 'selected': False, 'text': '<p>I\'m taking a look at : <a href="http://code.google.com/p/fjcore/source/checkout" rel="nofollow noreferrer">http://code.google.com/p/fjcore/source/checkout</a>\nA dependency free image processing library.</p>\n'}, {'answer_id': 97669, 'author': 'Lou Franco', 'author_id': 3937, 'author_profile': 'https://Stackoverflow.com/users/3937', 'pm_score': 2, 'selected': False, 'text': '<p>You could easily write crop yourself in fjcore.  Start with the code for Resizer</p>\n\n<p><a href="http://web.archive.org/web/20140304090029/http://code.google.com:80/p/fjcore/source/browse/trunk/FJCore/Resize/ImageResizer.cs?" rel="nofollow noreferrer">http://web.archive.org/web/20140304090029/http://code.google.com:80/p/fjcore/source/browse/trunk/FJCore/Resize/ImageResizer.cs?</a></p>\n\n<p>and FilterNNResize -- you can see how the image data is stored -- it\'s just simple arrays of pixels.</p>\n\n<p>The important part is:</p>\n\n<pre><code>for (int y = 0; y &lt; _newHeight; y++)\n{\n    i_sY = (int)sY; sX = 0;\n\n    UpdateProgress((double)y / _newHeight);\n\n    for (int x = 0; x &lt; _newWidth; x++)\n    {\n        i_sX = (int)sX;\n\n        _destinationData[0][x, y] = _sourceData[0][i_sX, i_sY];\n\n        if (_color) {\n\n            _destinationData[1][x, y] = _sourceData[1][i_sX, i_sY];\n            _destinationData[2][x, y] = _sourceData[2][i_sX, i_sY];\n        }\n\n        sX += xStep;\n    }\n    sY += yStep;\n}\n</code></pre>\n\n<p>shows you that the data is stored in an array of color planes (1 element for 8bpp gray, 3 elements for color) and each element has a 2-D array of bytes (x, y) for the image.</p>\n\n<p>You just need to loop through the destination pixels, copying then from the appropriate place in the source.</p>\n\n<p>edit: don\'t forget to provide the patch to the author of fjcore</p>\n'}]
['https://Stackoverflow.com/questions/37048', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/580/']