Jump to content

How do I create a layer that is smaller than the document size?


xchellx

Recommended Posts

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?

 

Link to comment
Share on other sites

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 by xchellx
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Fill the destination canvas with transparent pixels then copy the bitmap to position [0,0].

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...