Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7089461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:55:28+00:00 2026-05-28T07:55:28+00:00

I want to learn graphics programming, and I want to use Skia as the

  • 0

I want to learn graphics programming, and I want to use Skia as the library.
How do I begin with it on Ubuntu?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:55:29+00:00Added an answer on May 28, 2026 at 7:55 am

    Use the r1236 version. Newer versions of skia have issues on Linux.

    svn checkout http://skia.googlecode.com/svn/trunk -r1236
    
    // New URL: svn checkout http://skia.googlecode.com/svn/trunk_no_commit -r1236
    
    cd trunk
    

    Skia has font paths hard coded, so you want to change that.

    Edit src/ports/SkFontHost_linux.cpp

    Search “SK_FONT_FILE_PREFIX”

    Change “/usr/share/fonts/truetype/msttcorefonts/” to “/usr/share/fonts/TTF/”

    ./gyp/gyp_skia
    
    make
    

    You should now have libskia.a.

    #include "SkCanvas.h"
    #include "SkGraphics.h"
    #include "SkImageEncoder.h"
    #include "SkString.h"
    #include "SkTemplates.h"
    #include "SkTypeface.h"
    
    // g++ main.cpp -Wl,-rpath,./ -L. -lskia -Iinclude/core -Iinclude/config -Iinclude/images -lpthread -lfreetype -lpng -o main
    
    int main (int argc, char * const argv[]) {
    
        //
        SkAutoGraphics ag;
    
        //Output filename
        SkString path("skhello.png");
    
        //Set Text To Draw
        SkString text("Hydra v0.0.1a");
    
        SkPaint paint;
    
        //Set Text ARGB Color
        paint.setARGB(255, 255, 255, 255);
    
        //Turn AntiAliasing On
        paint.setAntiAlias(true);
        paint.setLCDRenderText(true);
        paint.setTypeface(SkTypeface::CreateFromName("sans-serif", SkTypeface::kNormal));
    
        //Set Text Size
        paint.setTextSize(SkIntToScalar(40));
    
        //Set Image Width & Height
        int width = 500;
        int height = 600;
    
        SkBitmap bitmap;
        bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
        bitmap.allocPixels();
    
        //Create Canvas
        SkCanvas canvas(bitmap);
        canvas.drawARGB(255, 25, 25, 25);
    
        //Text X, Y Position Varibles
        int x = 80;
        int y = 60;
    
        canvas.drawText(text.c_str(), text.size(), x, y, paint);
    
        //Set Style and Stroke Width
        paint.setStyle(SkPaint::kStroke_Style);
        paint.setStrokeWidth(3);
    
        //Draw A Rectangle
        SkRect rect;
        paint.setARGB(255, 255, 255, 255);
        //Left, Top, Right, Bottom
        rect.set(50, 100, 200, 200);
        canvas.drawRoundRect(rect, 20, 20, paint);
    
        canvas.drawOval(rect, paint);
    
        //Draw A Line
        canvas.drawLine(10, 300, 300, 300, paint);
    
        //Draw Circle (X, Y, Size, Paint)
        canvas.drawCircle(100, 400, 50, paint);
    
        //Same Image  (file, bitmap, image_type, quality)
        SkImageEncoder::EncodeFile(path.c_str(), bitmap, SkImageEncoder::kPNG_Type, 0);
    
        return 0;
    }
    

    Screenshot

    Here is an SFML2 and Skia example:

    #include <SFML/Graphics.hpp>
    #include "SkCanvas.h"
    #include "SkGraphics.h"
    #include "SkImageEncoder.h"
    #include "SkString.h"
    #include "SkTemplates.h"
    #include "SkTypeface.h"
    
    #include <iostream>
    
    // g++ main.cpp -Wl,-rpath,./ -L. -lskia -Iinclude/core -Iinclude/config -Iinclude/images -lpthread -lfreetype -lpng -lsfml-window -lsfml-graphics -lsfml-system
    
    using namespace std;
    
    int main(int argc, char **argv) {
    
        int width = 800;
        int height = 600;
    
        // Create the main window
        sf::RenderWindow window(sf::VideoMode(width, height), "SFML window");
        sf::Image image;
    
        SkAutoGraphics ag;
    
        //Set Text To Draw
        SkString text("Hydra Skia v0.0.1a");
    
        SkPaint paint;
    
        //Set Text ARGB Color
        paint.setARGB(255, 255, 255, 255);
    
        //Turn AntiAliasing On
        paint.setAntiAlias(true);
        paint.setLCDRenderText(true);
        paint.setTypeface(SkTypeface::CreateFromName("sans-serif", SkTypeface::kNormal));
    
        //Set Text Size
        paint.setTextSize(SkIntToScalar(20));
    
        SkBitmap bitmap;
        bitmap.setConfig(SkBitmap::kARGB_8888_Config, width / 2, height);
        bitmap.allocPixels();
    
        //Create Canvas
        SkCanvas canvas(bitmap);
        canvas.drawARGB(100, 25, 25, 25);
    
        //Text X, Y Position Varibles
        int x = 80;
        int y = 60;
    
        canvas.drawText(text.c_str(), text.size(), x, y, paint);
    
        //Set Style and Stroke Width
        paint.setStyle(SkPaint::kStroke_Style);
        paint.setStrokeWidth(3);
    
        //Draw A Rectangle
        SkRect rect;
        paint.setARGB(255, 0, 0, 0);
        //Left, Top, Right, Bottom
        rect.set(50, 100, 200, 200);
        canvas.drawRoundRect(rect, 20, 20, paint);
    
        canvas.drawOval(rect, paint);
    
        //Draw A Line
        canvas.drawLine(10, 300, 300, 300, paint);
    
        //Draw Circle (X, Y, Size, Paint)
        canvas.drawCircle(100, 400, 50, paint);
    
    
        image.Create(bitmap.width(), bitmap.height(), reinterpret_cast<const sf::Uint8*>(bitmap.getPixels()));
    
        // Load a sprite to display
        sf::Texture texture;
        if (!texture.LoadFromImage(image))
                return EXIT_FAILURE;
    
        sf::Sprite sprite(texture);
        //sprite.SetPosition(100, 100);
        //sprite.Resize(400, 400);
    
        // Load a sprite to display
        sf::Texture tex;
        if (!tex.LoadFromFile("background.jpg"))
               return EXIT_FAILURE;
        sf::Sprite texs(tex);
    
    
        // Start the game loop
        while (window.IsOpened())
        {
            // Process events
            sf::Event event;
            while (window.PollEvent(event))
            {
                // Close window : exit
                if (event.Type == sf::Event::Closed)
                    window.Close();
            }
    
            // Clear screen
            window.Clear();
    
            window.Draw(texs);
            window.Draw(sprite);
    
            // Update the window
            window.Display();
        }
    
        return EXIT_SUCCESS;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to learn how to use MSBuild ReadLinesFromFile Task I observe Output tag
I want to learn lLinux Kernel programming. What would be the starting points for
trying to learn windows programming in java, want to display a image to a
Hi guys I'm new to java graphics and I want to learn how to
I want to learn a new programming language and develop for the Android platform.
I am new in iPhone Developer so I want learn SQLite Database from begin
I want to learn to use vim. The thing is simple : I don't
I'm not a graphics person, but I want to learn silverlight development. Which expression
is there url for learning cake bake command. for example i want learn acl
I want to learn and work with initialize.php so I try to build simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.