Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerate image with some transparent parts
    primarykey
    data
    text
    <p>Im trying to generate a small square 32 by 32 pixels with a 10 by 10 squareish transparent gap in the middle.</p> <p>This is what I have so far:</p> <pre><code>private Image CreatePicture(){ // Create a new Bitmap object, 32 x 32 pixels in size Bitmap canvas = new Bitmap(32,32,System.Drawing.Imaging.PixelFormat.Format16bppRgb555); for(int i=10;i&lt;21;i++){ for(int p=10;p&lt;21;p++){ canvas.SetPixel(i,p,Color.Lime); } } canvas.MakeTransparent(Color.Lime); // return the picture return canvas; } </code></pre> <p>Its a it rough and not going to be the final "optimized version" its just a rough demo script. The problem is the returned image does not transparency instead its just a grey box :(.</p> <p>Any help appreciated.</p> <p>Michael</p> <p>UPDATE: I have updated the script with the PixelFormat set to an Alpha RGB format which it actually accepts without erroring on runtime. Now though if I remove the "canvas.MakeTransparent(Color.Lime);" line it shows a lime box in the middle with it it just shows a grey box the same colour as the grey background; so it seems as if transparency is being recognised just not implimenting the transparency!</p> <pre><code>private Bitmap CreatePicture(){ // Create a new Bitmap object, 50 x 50 pixels in size Bitmap canvas = new Bitmap(82,82,System.Drawing.Imaging.PixelFormat.Format32bppArgb); for(int i=10;i&lt;71;i++){ for(int p=10;p&lt;71;p++){ canvas.SetPixel(i,p,Color.Lime); } } canvas.MakeTransparent(Color.Lime); // return the picture return canvas; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload