Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
U

User 11678350

@User 11678350
About
Posts
4
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • LINQ Equivalent
    U User 11678350

    Below is my answer despite it is too late:

    var lines = File.ReadLines(filepath).ToArray();

    (
    from line in lines
    where !string.IsNullOrEmpty(line)
    select line.Split(',')[0]
    ).ToList()
    .ForEach(item => this.cboSiteLocation.Items.Add(item.Trim());

    LINQ csharp database linq tutorial

  • Windows 10 / D3D9 Master Adapter Failure
    U User 11678350

    IMHO, DX 9 is a planned obsolescence and it will be eventually abandoned. Why don't you start off by D3D11CreateDevice? Walkthrough: Port a simple Direct3D 9 app to DirectX 11 and Universal Windows Platform (UWP) - Windows app development[^]

    Graphics com question announcement

  • D2D/GDI+ Interop Problem
    U User 11678350

    I have recently read an article about Direct2D and GDI Interop from MSDN and I just wanted to make an attempt on that. The problem with my code is that there is no (D2D) red rectangles at the output file but it does not produce any compile-time or runtime errors. That really makes me frustrated as I have already spent my valuable weekend for that without any progress. :(( Any help is appreciated.:rose: Ref. article: Direct2D and GDI Interoperability Overview (Windows)[^] Code block:

    #include
    #include
    #include
    #include

    #pragma comment(lib, "d2d1.lib")
    #pragma comment(lib, "GdiPlus.lib")
    #pragma comment(lib, "Windowscodecs.lib")

    using namespace std;

    void main()
    {
    HRESULT hr;
    ID2D1Factory* factory;
    ID2D1DCRenderTarget* target;
    ID2D1SolidColorBrush* brush;

    D2D1CreateFactory(D2D1\_FACTORY\_TYPE\_SINGLE\_THREADED, &factory);
    
    // initialize GDI+
    ULONG\_PTR token;
    Gdiplus::GdiplusStartup(&token, new Gdiplus::GdiplusStartupInput(), nullptr);
    
    
    auto image = new Gdiplus::Image(L"C:\\\\temp\\\\test.jpg");
    
    auto g = Gdiplus::Graphics::FromImage(image);
    
    auto prop = D2D1\_RENDER\_TARGET\_PROPERTIES{
    	D2D1\_RENDER\_TARGET\_TYPE\_HARDWARE ,
    	D2D1\_PIXEL\_FORMAT{ DXGI\_FORMAT\_B8G8R8A8\_UNORM , D2D1\_ALPHA\_MODE\_PREMULTIPLIED },
    	144.0f,
    	144.0f,
    	D2D1\_RENDER\_TARGET\_USAGE\_GDI\_COMPATIBLE,
    	D2D1\_FEATURE\_LEVEL\_DEFAULT
    };
    
    
    hr = factory->CreateDCRenderTarget(&prop, &target);
    
    auto rect = RECT{ 0L,0L,800L, 600L };
    
    cout << boolalpha << (image == nullptr) << boolalpha << (g == nullptr) << endl;
    
    HDC deviceContext = g->GetHDC();
    
    // binds D2D device context to GDI+ device context.
    target->BindDC(deviceContext, &rect);
    
    // DrawRectangle using D2d
    target->BeginDraw();
    
    target->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Red, 1.0f), &brush);
    target->DrawRectangle(D2D1\_RECT\_F{ 5.0f,5.0f,10.0f,10.0f }, brush);
    target->DrawRectangle(D2D1\_RECT\_F{ 10.0f,10.0f,30.0f,30.0f }, brush);
    
    hr = target->EndDraw();
    
    cout << boolalpha << SUCCEEDED(hr) << endl;
    
    CLSID pngEncoderClsId = { 0x557cf406, 0x1a04, 0x11d3,{ 0x9a,0x73,0x00,0x00,0xf8,0x1e,0xf3,0x2e } };
    
    // Transcode and save as PNG image file
    image->Save(L"C:\\\\temp\\\\output.png", &pngEncoderClsId);
    
    Graphics com graphics help visual-studio winforms

  • how can i get this to work in c#
    U User 11678350

    I don't think it is productive to use a converter in this case because C# classes are managed classes while the given C++ class is a native one. For a Managed C++ (or formally, C++/CLI) class, we should write ref class instead of class - and objects are instantiated in this way:

    Object^ obj1 = gcnew Object(); // C++/CLI
    Object^ obj2 = ref new Object(); // C++/CX

    C# csharp c++ graphics question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups