png + opengl

by borghild.hedda » Sun, 15 Mar 2009 13:13:01 GMT


Sponsored Links
 Hi,

Is it possible to draw a png image and then to run opengl operations
on it with android?

Is this the right forum to ask this?
where can i get more information on doing such stuff?

Thanks

--~--~---------~--~----~------------~-------~--~----~



png + opengl

by Jon Colverson » Mon, 16 Mar 2009 04:41:31 GMT


 


What do you mean by "run opengl operations on it"? You can certainly
use a PNG bitmap as a background and then do 3D stuff on top of it.

--
Jon

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. I wana ask about creating own views

I have created my ownView (extend class View) and override function
onDraw() in it
I wanted to use it in my xml file design :D
but when i put it inside the file an error happens when the program
runs so if anyone can help me to do so as i make whole imnterface
using xml and i wanna add this new class in between.

The code:
This is the new view:
package com.android.mobi3.player;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Paint.Style;
import android.view.View;

/**
 *
 * @author Ahmed Abdel Samea
 * This Class is used to provide a view to user to draw
 * the seek bar.
 *
 */
public class SeekTimer extends View {

        /
*---------------------------------------------------------------------------
*/
        /
*---------------------------------------------------------------------------
*/
        /
*---------------------------------------------------------------------------
*/
        /*                                                      Variables Area
        /
*---------------------------------------------------------------------------
*/
        /
*---------------------------------------------------------------------------
*/
        /
*---------------------------------------------------------------------------
*/

        //width of the drawing
        protected final int ARCSTROKEWIDTH = 20;
        //values
        protected int mySecondsPassed = 0;
    protected int mySecondsTotal = 0;
    //used to draw the timer by no. and seek bar
    protected final Paint myArcSecondPaint = new Paint();
    protected final Paint myArcMinutePaint = new Paint();
    protected final Paint myCountDownTextPaint = new Paint();

    /
*---------------------------------------------------------------------------
*/
        /
*---------------------------------------------------------------------------
*/
        /
*---------------------------------------------------------------------------
*/
        /*                                                      Constructor
        /
*---------------------------------------------------------------------------
*/
        /
*---------------------------------------------------------------------------
*/
        /
*---------------------------------------------------------------------------
*/

        public SeekTimer(Context context) {
                super(context);
                  /******************************************************/
              /**----   Setting the timer and seek bar drawer   ----*/
              /******************************************************/

             // Black text for the countdown
                this.myCountDownTextPaint.setARGB(150, 0, 0, 0);
                this.myCountDownTextPaint.setTextSize(110);
                this.myCountDownTextPaint.setFakeBoldText(true);

             // Our arc fill be a lookthrough-red.
                this.myArcMinutePaint.setARGB(150, 170, 0, 0);
                this.myArcMinutePaint.setAntiAlias(true);
                this.myArcMinutePaint.setStyle(Style.STROKE);
                this.myArcMinutePaint.setStrokeWidth(ARCSTROKEWIDTH);

                this.myArcSecondPaint.setARGB(200, 255, 130, 20);
                this.myArcSecondPaint.setAntiAlias(true);
                this.myArcSecondPaint.setStyle(Style.STROKE);
                this.myArcSecondPaint.setStrokeWidth(ARCSTROKEWIDTH / 3);
        }

        // ===========================================================
    // Getter & Setter
    // ===========================================================

    public void updateSecondsPassed(int someSeconds){
         this.mySecondsPassed = someSeconds;
    }

    public void updateSecondsTotal(int totalSeconds){
         this.mySecondsTotal = totalSeconds;
    }

    public int getSecondsPassed(){
        return mySecondsPassed;
    }

    @Override
    protected void onDraw(Canvas canvas) {
         /* Calculate the time left,
          * until our pizza is finished. */
        int secondsLeft = this.mySecondsTotal - this.mySecondsPassed;

        if(secondsLeft>0){
              // At least one second left
              float angleAmountMinutes = ((this.mySecondsPassed *
1.0f)
                                                      /
this.mySecondsTotal)
                                                      * 360;
              float angleAmountSeconds = ((60 -secondsLeft % 60) *
1.0f)
                                                      / 60
                                                      * 360;

              /* Calculate an Rectangle,
               * with some spacing to the edges */
              RectF arcRect = new RectF(ARCSTROKEWIDTH / 2,
                                       ARCSTROKEWIDTH / 2,
                                       this.getWidth() -
ARCSTROKEWIDTH / 2,
                                       this.getHeight() -
ARCSTROKEWIDTH / 2);

              // Draw the Minutes-Arc  into that rectangle
              canvas.drawArc(arcRect, -90, angleAmountMinutes,
 
this.myArcMinutePaint);

              // Draw the Seconds-Arc  into that rectangle
              canvas.drawArc(arcRect, -90, angleAmountSeconds,
 
this.myArcSecondPaint);

         }
    }

}


code and I wrote in the xml:(I write it in relative layout)

Line 23: <SeekTimer android:id="@+id/seek_bar"
                android:layout_width="50px"
                android:layout_height="50px"
                android:layout_centerHorizontal="true"/>

The error that i get:

ComponentInfo{com.android.mobi3.player/
com.android.mobi3.player.PlayerGUI}
android.view.ViewInflate$Inflate Exception: Binary XML file line
#23:Error inflating class SeekTimer.
--~--~---------~--~----~------------~-------~--~----~

2. ImageView/ImageButton question

Hi,

I'm having trouble setting the image on either of those
programmatically. If I specify something in the XML it'll work fine, but
I can't seem to find how to specify the image in the code itself.  This
is my code snippet:

ImageButton ib = (ImageButton) findViewById(R.id.image_button_id);
ib.setImageURI(Uri.parse((imageURL)));

Where imageURL is a string. Do I need to then set this to active
somehow? All I keep getting is a blank ImageButton.

Thanks,
Ahmad

--~--~---------~--~----~------------~-------~--~----~

3. GTalk Sender unable to make session

4. getting Media File metadata?

5. Console error message

6. Android Developer Registry

7. Bug :: Spinner + arrays of numbers in array.xml