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

  • SEARCH
  • Home
  • 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 8856553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:22:56+00:00 2026-06-14T14:22:56+00:00

I have 3 projects: desktop_starter , android_starter and platform . Both the starter projects

  • 0

I have 3 projects: desktop_starter, android_starter and platform. Both the starter projects references the platform project, and the platform project is supposed to be (99%) platform independent, and contains almost all code.

The reason is ofcourse that I want to be able to run the android app on the desktop without having to use the emulator.

However at least on one place I need to call platform-specific code in platform. Specifically I need to use javax.ImageIO on desktop or android.graphics.Bitmap to read an image pixel by pixel.

As there is no preprocessor or similar constructs in java AFAIK, what are my choices?

  • I could send in the image-reader as an Object to platform and use reflection I guess, but thats dirty.
  • I find a built-in image reader that works on both desktop java and android, any ideas?
  • JNI and use libpng or something like that I guess, seems as there should be an easier way.
  • 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-14T14:22:57+00:00Added an answer on June 14, 2026 at 2:22 pm

    You could simply code the platform code on an interface defining the methods you need, and pass a platform-specific implementation of this interface from the platform-specific project.

    For example, if what you need is an int array containing all the pixels of the image (just an example), the interface would be:

    public interface ImageReader {
        int[] getImagePixels(InputStream in) throws IOException;
    }
    

    And you would have two implementations of the interface: one using ImageIO internally, in the desktop project, and the other using Bitmap internally, in the android project. An instance of one of those classes would be passed to the platform-independant code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All of my cross-platform libraries are created with solutions that have two projects: one
I have a solution that contains both a Silverlight 4 and a WPF 4
I have a Java EE 6 project I'm developing in NetBeans. All of the
Work on C# Desktop project,I have an account on paypal ,From my desktop application
Here is my scenario: I have an Eclipse project in my desktop in a
I have written the following code, CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(@C:\Users\XXX\Desktop\Backup1\Project\ReportsFolder\ReportSalesInvoice.rpt); Report works
I have projects that need to be build with a specific version of the
I'm running wamp on Vista (Apache v2.2.11) and have projects setup such that http://localhost/projectx
I am using apache ant in the following way: I have projects P1, P2,
Projects have many tasks and a task has a custom RESTful action called 'approve'.

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.