xchellx Posted February 1, 2021 Share Posted February 1, 2021 I am making a FileType plugin where I read mipmap data from the file. Each mipmap is 2x smaller than each mipmap read. The issue is, having each layer the same size as the document size while using `CopyFromGdipBitmap` causes the image to repeat for the entire width of the image (not for the height though). Yes I am converting to bitmap then using `CopyFromGdipBitmap` because the file stores texture data in sequences of blocks of various sizes, and in the end its stored into an array full of pixel data but not x/y coordinates. Ergo I cant do `layer.Surface[x, y] = ...;`. How do I create a layer that is smaller in size compared to the document? Or is there an alternative to `CopyFromGdipBitmap` that supports data that is smaller than the document/layer? Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted February 1, 2021 Share Posted February 1, 2021 In Paint.NET, layers are always the same size as the document. Perhaps that will change some day, but for now, you'll have to work around the limitation. Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
xchellx Posted February 1, 2021 Author Share Posted February 1, 2021 (edited) is there at least a way to use `ImageRendererBgra` to render an image smaller than the layer on it's surface? On Render, I get `System.ArgumentException: 'srcBounds ({X=0,Y=0,Width=128,Height=64}) does not contain renderBounds ({X=0,Y=0,Width=256,Height=128})'` Edited February 1, 2021 by xchellx Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted February 1, 2021 Share Posted February 1, 2021 Do not use ImageRendererBgra, that's an internal class and will likely be changed or refactored, and your plugin will break. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
xchellx Posted February 1, 2021 Author Share Posted February 1, 2021 Then what do I use? How do I render a Bitmap that is smaller than a layer on it's Surface? Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted February 3, 2021 Share Posted February 3, 2021 On 2/2/2021 at 11:52 AM, xchellx said: ......to render an image smaller than the layer ..... Render the image in the top left hand corner and make all the other pixels transparent. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
xchellx Posted February 3, 2021 Author Share Posted February 3, 2021 15 hours ago, Ego Eram Reputo said: Render the image in the top left hand corner and make all the other pixels transparent. How do I do that? All I have to render a Bitmap is `CopyFromGdipBitmap` and `CopySurface` with `Surface.CopyFromBitmap`. I could choose the top left rendering point with `ImageRendererBgra` but as Rick said, that is an internal class I shouldn't use. Again, I can't do the x,y pixel coordinates due to the way the target format handles pixel coordinates. Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted February 3, 2021 Share Posted February 3, 2021 Fill the destination canvas with transparent pixels then copy the bitmap to position [0,0]. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
MJW Posted February 3, 2021 Share Posted February 3, 2021 Not that it really matters to me, but why do you want to load all the lower order mipmaps into PDN layers? Usually the lower maps are automatically generated from the top level map, so only the top level needs to be edited. I would expect the lower-level maps to be produced from the top level when the image is saved as a mipmap file. Quote Link to comment Share on other sites More sharing options...
xchellx Posted February 4, 2021 Author Share Posted February 4, 2021 Again, I can't do it pixel by pixel. I decode blocks of pixels to a pixel array but the x/y coordinates are never known in the end. However I do convert the data to a Bitmap in the end. Also, this game's texture format (.TXTR) stores all it's mipmaps in it's texture data section. In it's header there is a mipmap count. Mipmap auto generation is never done here. Quote Link to comment Share on other sites More sharing options...
xchellx Posted February 4, 2021 Author Share Posted February 4, 2021 In the end, I ended up making a standalone .NET application with Bitmap.Save. All the mipresults came out correctly. This is because I could create a bitmap each with it's own size for every mipmap iteration. It's too bad Paint.NET's API cannot handle graphics of various different sizes, at least from the API side. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted February 5, 2021 Share Posted February 5, 2021 All Layers in the same Document must be the same size. I'm still not really sure what you're trying to do. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.