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 8153881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:09:36+00:00 2026-06-06T16:09:36+00:00

I am using Skia (prebuilt) to draw in an android native window, that i

  • 0

I am using Skia (prebuilt) to draw in an android native window, that i get from a java surface. The code performs well on every device I could test it on, except for a Samsung Galaxy S3 (with android 4.0.4 on it). The first image is what I should see, and the second what appears on the Galaxy S3:

Screenshot of the test on an emulator: shows a red rectangle
Screenshot of the test on a Samsung Galaxy S3: shows a series of red-on-black diagonal stripes

The jni function that draws the rectangle is:

JNIEXPORT void JNICALL Java_com_test_TestSkia_InitializeWindow(JNIEnv* env, jobject thiz, jobject surface)
{
     ANativeWindow* window = ANativeWindow_fromSurface(env, surface);
     ANativeWindow_Buffer buffer;
     ANativeWindow_lock(window, &buffer, NULL);
     SkBitmap  bitmap;
     bitmap.setConfig(convertPixelFormat(buffer.format), buffer.width, buffer.height);
     bitmap.setPixels(buffer.bits);
     SkCanvas canvas;
     canvas.setBitmapDevice(bitmap);
     SkRect rectRed;
     rectRed.setXYWH(30,30,400,700);
     SkPaint paint;
     paint.setColor(SK_ColorRED);
     canvas.drawRect(rectRed,paint);
     ANativeWindow_unlockAndPost(window);
}

I tested it on the following devices, with no issue:

  • Sony X8 (android 2.3.7 customized rom)
  • Samsung Nexus S (android 4.0.4)
  • Samsung Galaxy Tab 10.1 (android 3.2)
  • Samsung Galaxy S2 (android 2.3.5)
  • Emulator (android 4.0.3, same screen size and dpi than the galaxy S3)

I tried calling ANativeWindow_setBuffersGeometry(window,0,0,0) with no luck (anyway, the buffer’s dimensions and format after the window lock appear to be ok).

So far, only the Galaxy S3 is giving me troubles, at this point I don’t know what to do, I can’t even tell if the problem is with the ndk native window api or with skia, or maybe it is related to the galaxy S3 using TouchWiz… any idea would be welcome!

  • 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-06-06T16:09:38+00:00Added an answer on June 6, 2026 at 4:09 pm

    You need to take buffer.stride into account. Your picture clearly shows that you are having buffer.stride != buffer.width

    I’m not able to test, but probably the following change is enough:

     SkBitmap bitmap;
     SkBitmap::Config cfg = convertPixelFormat(buffer.format);
     bitmap.setConfig(cfg, buffer.width, buffer.height,
           SkBitmap::ComputeBytesPerPixel(cfg) * buffer.stride);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code from android developer blog for downloading a BMP file
Using Java,I have to fetch multiple sets of values from an XML file to
Using Yii, I want to delete all the rows that are not from today.
Using DMD 2.057, I cannot get the following code to compile: import std.stdio; import
Using ThreadPoolRuntime, I could get a throughput attiribute that means The mean number of
Using the Redis info command, I am able to get all the stats of
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
Using android 2.3.3, I have a background Service which has a socket connection. There's
I have written the code to select a folder from the SDCard and its
Using mercurial, I've run into an odd problem where a line from one committer

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.