A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Drawing Image in its original size. Help.

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    1

    Drawing Image in its original size. Help.

    Hello Everyone.
    I just started Actionscript 3.0 for making games. I Have been developing games using Opengl, J2me.
    I started with a simple code to draw image. But i didn't get the expected results. What i got is:
    1) Image gets rendered but it gets scaled to high resolution and images gets distorted.

    So i wanted to draw image in its original size. If image size is 300*400 then i want to get it drawn in its original size.
    I google searched and try to find on how to achieve it. But no success. So here i am here, if anyone could help me ??

    i want to know how to achieve this two things:
    1) drawing image in its original size, i don't want it to get scaled .
    2) how to set the size of display screen ? when i ran the code, the display screen(flash) cover whole browser page area ? I want to set the screen size to 450*300

    I am using Flash Builder 4 for making actionscript project. Here is the code :
    Code:
    package
    {
    	import flash.display.Bitmap;
    	import flash.display.Sprite;
    	
    	public class Gaanza extends Sprite
    	{
    		private var backGround:Bitmap;
    		
    		[Embed (source='res/BG.png')] private var bgClass:Class;
    		
    		public function Gaanza()
    		{
    			//this.height=300;
    			//this.width=300;
    			//stage.height=300;
    			//stage.width=300;
    			backGround =new bgClass();
    			backGround.x=0;
    			backGround.y=0;
    			this.addChild(backGround);
    		}
    	}
    }
    Please Help.
    Thanks.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Assuming that code is your document class, it will draw the image at native resolution. But if the swf is scaled, the image will scale with it. If you are hitting the swf directly with the browser, it will scale to the browser dimensions by default.

    To control the size of the whole swf, you set it with the width and height of the embedding html code. You could also play with the Stage.scaleMode and Stage.align properties. Setting the scaleMode to StageScaleMode.NO_SCALE should prevent it from resizing. And setting the align to StageAlign.TOP_LEFT should ensure that it is aligned in the top left of the display area of the flash player.

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    22
    If equipped with a professional image drawing toolkit, we can draw both text and graphics on the original image without affecting its size or resolution. I give my prorgammed methods blow, hope it can be helpful.

    public void RectangleDrawing(Pen mypen, Rectangle myRectangle);
    public void RectangleDrawing(Pen mypen, Point pt1, Point pt2);
    public void EllipseDrawing(Pen maypen, Point pt1, Point pt2, Point pt3, Point pt4);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center