Skip to content

Graphics

DirectX, OpenGL and GDI/GDI+ discussions

This category can be followed from the open social web via the handle graphics@forum.codeproject.com

769 Topics 2.5k Posts
  • How to make an image (bmp) transparent?

    question tutorial
    3
    0 Votes
    3 Posts
    3 Views
    R
    The GDI+ code that will make the image semi-transparent is to create a custom color matrix. This topic is too lengthy to get into specifics but here is some sample code the will get you started: //Define a color matrix that has 60% transparency //The value 0.6 in row 4, column 4 specifies the alpha float[][] matrixItems = { new float[] {1,0,0,0,0}, new float[] {0,1,0,0,0}, new float[] {0,0,1,0,0}, new float[] {0,0,0,0.6f,0}, new float[] {0,0,0,0,1}}; ColorMatrix colorMatrix = new ColorMatrix(matrixItems); //Now we need an ImageAttributes object ImageAtttributes imageAtt = new ImageAttributes(); imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, COlorAdjustType.Bitmap); //Here, we will now draw the image using the imageAtt //You will need to have a graphics object created. I am //using a graphics object with a var name of "g" g.DrawImage( myAlphaBitmap, //the image to be made semi-transparent new Rectangle(10,10,10,10), //destination bmp size 0.0f, //start drawing from the XPos 0.0f, //start drawing from the YPos myAlphaBitmap.Width, //draw all of the original width myAlphaBitmap.Height, //draw all of the original height GraphicsUnit.Pixel, //specify the graphics unit imageAtt); //use our custom imageAtt //release system resources imageAtt.Dispose(); //End of code---------------------------- Hopefully this will get you started in the right direction! Cheers! Richard may your code be error free
  • How to calculate the number of lines in .Png file

    c++ tutorial
    3
    0 Votes
    3 Posts
    3 Views
    L
    this may help you[^] Luc Pattyn [Forum Guidelines] [My Articles] this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google
  • Add water Mark to a video

    help
    2
    0 Votes
    2 Posts
    4 Views
    J
    You have to specify the type of video file ur using , if it is uncompressed AVI , simply you can decode the avi and grab each frame , add ur water mark image or text to that. If ur video file is mpeg or wm files, better to write this part as a filter. Also you should have the corresponding decoderes and encoderes, for example mpegvideo - >decode -> raw video-> ur filter -> again encode -> write to file :) If u can Dream... U can do it
  • Cursor not shown in textBox

    csharp
    2
    0 Votes
    2 Posts
    4 Views
    M
    You may get a better response on the C# board[^] Mark Mark Salsbery Microsoft MVP - Visual C++ :java:
  • Horizontal Expanding Docking Panel (web)

    help question
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • benefit of Map File in Visual C++ ???

    c++ question
    5
    0 Votes
    5 Posts
    5 Views
    M
    Thank U again Luc Pattyn:rose:... yes i have openned one of these files (map files) using text editor.. :) maria
  • applying texture to bitmap [modified]

    graphics winforms com question
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Anoone tell me how to crack MAYA Unlimite v8

    tutorial
    3
    0 Votes
    3 Posts
    4 Views
    P
    Well that's a good idea. Come onto a public site and then ask people to help you break the law. While we're at it, should we drive the getaway car while you rob the bank? Berk. Deja View - the feeling that you've seen this post before.
  • draw and select object

    graphics winforms help question
    9
    0 Votes
    9 Posts
    4 Views
    C
    here is another approach the first thing you need to do is make a stack which supports all the graphics you are using: MyGraphicsStack; MyGraphicsStack.add( line, rect, color, ... ); <- user draws a line MyGraphicsStack.add( circle, rect, color, ..., fill ); <- user draws .. . . (or better, make objects and inherit from the same base class) Now when the user clicks, you create a white temporary bitmap with the same dimensions as the user is drawing on. the next thing is drawing your stack ( in the correct order ) on this temporary bitmap. For each item you are drawing, ignore the color in the GraphicsStack but use instead: (COLORREF)index_Of_Current_Object_In_MyStack. (index casting to a color) for filled objects: use this color for the fill/and the border color. Then transform your mouse coordinates where the user clicked, to bitmap coordinates. And for this coordination obtain the bitmap pixel color. When you cast the pixel color back it will be the index of the object kept in your stack, ( or white in case user pressed the bitmap ) UINT nInd = (COLORREF)getpixel(..) if ( nInd < MyGraphicsStack.Size( ) ) { MyGraphicsStack[ nInd ] //<-- here it is } in this way you have always the topmost object even when objects are drawn over each other. You also distinct objects which are filled or not. ( depending on the bit depth of the bitmap you are creating you are limited in the number of items you can draw, in that case you could work with more bitmaps, for a normal 24 bits bitmap you can keep 16777216 - 1 objects 1 = bitmap itself ) remark: Because Gdi+ plus can ignore drawing objects you are drawing outside the region of the dc, you can also create a small bitmap (I think 16x16 is the minimum?) and when drawing to this bitmap correct for the offset ( the bitmap coordinates the user selected ) in this way that the centre pixel of your small bitmap is the pixel you are interested in. well have fun!
  • HELP:: OpenGL code bugs

    graphics help game-dev data-structures json
    8
    0 Votes
    8 Posts
    4 Views
    E
    sagetarian wrote: Once again... why merge 'em This was a failed attempt to create one non-competing standard for all platform graphics, replacing both DirectX and OpenGL. It failed because of the power struggle within the committee. Sun still holds a grudge against MS and MS still holds a grudge against a few others. The idea was that without the competition they could work on creating a super set of functionality on the scale of a full scenegraph as well as low-level functionality. The project tore itself apart internally and the result was we still have DirectX and OpenGL as competitors for "some" markets. Some meaning that cross platform there still is no choice. In OpenGL 2.0+ you can do some GPU programming. It at least doesn't prevent you, you even have a choice of GPU languages depending on your personal favorites (CUDA, Cg, OSL, etc.). I've been doing GPU programming using vendor extensions since 1.5 was released. _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
  • 0 Votes
    1 Posts
    1 Views
    No one has replied
  • camera opengl

    graphics game-dev question help lounge
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • .NET Image Processing library for WinCE

    csharp help question
    3
    0 Votes
    3 Posts
    4 Views
    M
    Thanks for the reply. I have seen Accusoft but they are not cheap! Regards, Myron
  • how can i get the graphics

    question csharp graphics
    2
    0 Votes
    2 Posts
    3 Views
    L
    ok you just see it on trenster and you can select it again it easy sonarat I don't know how to tell you but I like IT and Designingas well as Graphic
  • Fake webcam?

    csharp question
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • reading vectors values of type static from file

    c++ graphics game-dev question
    5
    0 Votes
    5 Posts
    5 Views
    M
    thank U again El Corazon for UR rich information about my question.. frankly, i'll avoid the complexity and errors which may be accured when data r read from file. both of UR opinions are satisfactory and perfect.. I have built my program upon UR first opinion, i'll keep UR second perfect suggestion for future work :). regards maria -- modified at 14:42 Sunday 29th July, 2007
  • DirectX in C#

    csharp c++ graphics game-dev help
    3
    0 Votes
    3 Posts
    3 Views
    M
    I don't know about embedding applications in forms, but... The newer/newest DirectX SDKs include separate documentation for managed languages. The info should be there. Introducing DirectX 9.0 for Managed Code[^] Mark Mark Salsbery Microsoft MVP - Visual C++ :java:
  • Help wuth click map

    graphics help question
    2
    0 Votes
    2 Posts
    4 Views
    C
    Create a second bitmap with the same dimensions which you don't display. Give each unique area a unique color. The next step is, when the user clicks your bitmap get the mouse coordinates relative to your bitmap and use these coords on your internal map. DWORD ID = GetPixel( x, y ); switch ( ID ) { case 12: //South African; }
  • How to match a usb camera between DirectShow and WMI?

    regex help tutorial question
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Get Lighter / Darker color

    help tutorial csharp asp-net
    2
    0 Votes
    2 Posts
    2 Views
    L
    Hi, you could convert to HSB (hue, saturation, brightness) using Color.GetXXX() methods, adjust brightness a bit, (watch out for over/underflow) and convert back. You need to write that part yourself ! This article[^] is my preferred article for june and may help you. BTW in the Java world GetLighter() and GetDarker() (or something of that nature) do exist. :) Luc Pattyn try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }