Jump to content
Xtreme .Net Talk

OnErr0r

Members
  • Posts

    19
  • Joined

  • Last visited

1 Follower

Personal Information

  • Visual Studio .NET Version
    03

OnErr0r's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. My mother read me programming books in the womb. ;)
  2. I did go ahead and test that. I just added: bmp.MakeTransparent(System.Drawing.Color.Black) And it does make the background transparent. (unfortunately my image is not an entirely black background, but oh well) So this method would work well for drawing sprites quickly too.
  3. I didn't test that, but hopefully the CachedBitmap inherits the transparent properties of the bitmap from which it is based.
  4. This outta do it: Dim g As Graphics = Graphics.FromHwnd(Handle) Dim i As Integer For i = 0 to 360 g.RotateTransform(i) g.TranslateTransform(IMG_SIZE \ 2, IMG_SIZE \ 2, Drawing2D.MatrixOrder.Append) g.DrawImage(bmp, IMG_SIZE \ 2, IMG_SIZE \ 2, -IMG_SIZE, -IMG_SIZE) g.ResetTransform Next i g.Dispose
  5. I just thought I'd throw this out there. It's an example of using GDI+ CachedBitmap, which is about 3x faster than DrawImage. But probably not faster than BitBlt. CachedBitmap is really only handy when the bitmap that it is based upon is not going to change. If the base were to change, you'd have to Destroy the old and create a new CachedBitmap. And that is not very efficient.cachedbitmap.zip
  6. C++ programmers have a choice of using MC++ and the managed .net wrapper, or they could use the C++ classes written to wrap the gdiplus.dll directly. In VB5/6 you can use the exports of the gdiplus.dll as well.
  7. The main volume is accessible using [api]auxSetVolume[/api].
  8. You could LockBits on the bitmap, then either use unsafe and access the pixels directly (fast). Or, use Marshal.Copy to copy from the Scan0 IntPtr to an array, alter various pixels in said array and Marshal.Copy it back (relatively slow). Then UnlockBits.
  9. If the image has a palette, then you can get the alpha setting of a particular color using b.Palette.Entries(index).A(). If A() is < 255 then there is some alpha transparency set for the color at index. You'd check each color in a loop. Or, if the image has no palette, then use the code in the url provided.
  10. If you're talking about a paletted image 2-256 colors then you can look at the palette fairly quickly using b.Palette.Entries(index).A(). I think the .net implmentation gets a little confused with 8 bit (and less) images as b.Palette.Flags() is not equal to HasAlpha as expected (System.Drawing.Imaging.PaletteFlags HasAlpha), most likely because it's in 32 bit mode (or thinks it is) If the image is not paletted then you're stuck looking through the image for alpha. Here is an example searching an image using unsafe: http://www.fawcette.com/vsm/2003_06/magazine/columns/desktopdeveloper/ Removing transparency is just a matter of setting the alpha component of a color to 255.
  11. You could give your bitmap a broader scope and do the following: Private Sub Your_Event(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Whatever If ofd.ShowDialog = DialogResult.OK Then b = new bitmap(ofd.FileName) pbImage.Invalidate End If End Sub Private Sub pbImage_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pbImage.Paint If Not (b Is Nothing) Then e.Graphics.DrawImage(DirectCast(b, Drawing.Image), pbimage.ClientRectangle) End Sub
  12. If you would use GdipCreateBitmapFromScan0 or the bitmap constructor that wraps it: public Bitmap ( System.Int32 width , System.Int32 height , System.Int32 stride , System.Drawing.Imaging.PixelFormat format , System.IntPtr scan0 ) you could just have Scan0 point to the data and create the bitmap from that data all at once, no copying. After the bitmap has been created, you can LockBits and use Scan0 to alter it's pixels, then UnlockBits when done.
  13. One of the bitmap constructors wraps the GdipCreateBitmapFromScan0 function. So you can pass the address of your bitmap and the other required information to create a bitmap object.
  14. Since the constructor you're using is only specifying the filename as a string, the bitmap class is defaulting to (I believe) 32 bits. Since 32 bit has no palette, it's likely being ignored. You'll most need to include a PixelFormat arg as well.
  15. I'm very new to C#, but what if you created a generic function like this: uint RolRight(uint x, byte y, byte b) // number, shift, bits { //#define ROTR(x,y,b) (((x)>>(y&((b)-1))) | ((x)<<((b)-(y&((b)-1))))) return (x >> (y & (b - 1))) | (x << (b - (y & (b - 1)))); } And called it like one of these: byte Ret = (byte)RolRight(0x81, 1, 8); ushort Ret = (ushort)RolRight(0x8001, 1, 16); uint Ret = RolRight(0x80000001, 1, 32);
×
×
  • Create New...