Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C#

Name: Anonymous 2011-09-12 7:59

C/C++

memcpy(Screen, Pixels, Width*Height);


C#

using System;

using System.Collections.Generic;

using System.Text;

using System.Diagnostics;

using System.Drawing;

using System.Drawing.Imaging;

using System.Drawing.Drawing2D;

using System.IO;

using System.Runtime.InteropServices;

using IlbEditorNet;





namespace AoWGraphics

{

    public class AowRect

    {

        int top;

        int left;

        int right;

        int bottom;



        public int Top

        {

            get { return top; }

            set { top = value; }

        }

        public int Left

        {

            get { return left; }

            set { left = value; }

        }

        public int Right

        {

            get { return right; }

            set { right = value; }

        }

        public int Bottom

        {

            get { return bottom; }

            set { bottom = value; }

        }



        public int Width

        {

            get { return right - left + 1; }           

        }

        public int Height

        {

            get { return bottom - top + 1; }

        }   



        public AowRect()

        {

        }



        public AowRect(int top, int left, int right, int bottom)

        {

            Set(top, left, right, bottom);

        }



        public void Set(int top, int left, int right, int bottom)

        {

            this.top = top;

            this.left = left;

            this.right = right;

            this.bottom = bottom;

        }



        public void Set(AowRect rect)

        {

            this.top = rect.top;

            this.left = rect.left;

            this.right = rect.right;

            this.bottom = rect.bottom;

        }



        public bool IsValid()

        {

            return right > left && bottom > top;

        }

    }

   


    public abstract class  AoWBitmap : IDisposable, ICloneable

    {   

        // used by editor

        protected Bitmap _original = null;

        protected Bitmap _resized = null;

        protected Int32 _cX;

        protected Int32 _cY;



        protected ScalingType _scalingType = ScalingType.None;

        protected InterpolationMode _interpolationMode = InterpolationMode.High;

        protected float _scalingFactor = 1.0f;

        protected Int32 _scaleXTo;

        protected Int32 _scaleYTo;

        protected bool _dropTransparent = false;

        protected Int32 _dropThreshold = 16;

       

        public Bitmap Original

        {

            get { return _original; }

            set { _original = value; }

        }

        public Bitmap Resized

        {

            get { return _resized; }

            set { _resized = value; }

        }

        public Int32 CX

        {

            get { return _cX; }

            set { _cX = value; }

        }

        public Int32 CY

        {

            get { return _cY; }

            set { _cY = value; }

        }

       

        public ScalingType ScalingType

        {

            get { return _scalingType; }

            set

            {

                _scalingType = value;

                if (_scalingType == ScalingType.None || _scalingType == ScalingType.Fixed)

                    _scalingFactor = 1.0f;

            }

        }

        public InterpolationMode InterpolationMode

        {

            get { return _interpolationMode; }

            set { _interpolationMode = value; }

        }

        public float ScalingFactor

        {

            get { return _scalingFactor; }

            set { _scalingFactor = value; }

        }

        public Int32 ScaleXTo

        {

            get { return _scaleXTo; }

            set { _scaleXTo = value; }

        }

        public Int32 ScaleYTo

        {

            get { return _scaleYTo; }

            set { _scaleYTo = value; }

        }

        public bool DropTransparent

        {

            get { return _dropTransparent; }

            set { _dropTransparent = value; }

        }

        public Int32 DropThreshold

        {

            get { return _dropThreshold; }

            set { _dropThreshold = value; }

        }

               

        // used to encode

        protected AoWImageType _imageType = AoWImageType.Type02_RLESprite08_0x02;

        protected AoWImageSubType _subType = AoWImageSubType.SubType03;

        protected String _name;

        protected Int32 _imageNumber;

        protected Int32 _instanceNumber;

        protected Int32 _imageDataSize;

        protected Int32 _imageDataOffset;

        protected Int32 _numPalette;

        protected AowRect _boundingBox = new AowRect();       

        protected UInt32 _originalBackgroundColour = 0;

        protected UInt32 _resizedBackgroundColour = 0;



        protected Int32 _xShift;

        protected Int32 _yShift;

        protected AoWAutoShift _autoShift = AoWAutoShift.None;

        protected AoWLoadMode _loadMode = AoWLoadMode.lmWhenUsed;

        // used for blend

        protected AoWShowMode _showMode = AoWShowMode.smOpaque;

        protected AoWBlendMode _blendMode = AoWBlendMode.bmAlpha;

        protected Int32 _blendValue = 0;



        // force this value for type 17 and 18

        // because I don't  know its meaning

        protected AoWClipXHack _clipXHack = AoWClipXHack.None;



        // subimage list

        protected List<AoWBitmap> _subImageList = new List<AoWBitmap>();

       

        public AoWImageType ImageType

        {

            get { return _imageType; }

            set { _imageType = value; }

        }

        public AoWImageSubType SubType

        {

            get { return _subType; }

            set { _subType = value; }

        }

        public String Name

        {

            get { return _name; }

            set { _name = value; }

        }

        public Int32 ImageNumber

        {

            get { return _imageNumber; }

            set { _imageNumber = value; }

        }

        public Int32 InstanceNumber

        {

            get { return _instanceNumber; }

            set { _instanceNumber = value; }

        }

        public Int32 ImageDataSize

        {

            get { return _imageDataSize; }

            set { _imageDataSize = value; }

        }

        public Int32 ImageDataOffset

        {

            get { return _imageDataOffset; }

            set { _imageDataOffset = value; }

        }

        public Int32 NumPalette

        {

            get { return _numPalette; }

            set { _numPalette = value; }

        }       

        public AowRect BoundingBox

        {

            get { return _boundingBox; }

            set { _boundingBox = value; }

        }

        public UInt32 OriginalBackgroundColour

        {

            get { return _originalBackgroundColour; }

            set { _originalBackgroundColour = value; }

        }

        public UInt32 ResizedBackgroundColour

        {

            get { return _resizedBackgroundColour; }

            set { _resizedBackgroundColour = value; }

        }

        public Int32 XShift

        {

            get { return _xShift; }

            set { _xShift = value; }

        }

        public Int32 YShift

        {

            get { return _yShift; }

            set { _yShift = value; }

        }



        public AoWLoadMode LoadMode

        {

            get { return _loadMode; }

            set { _loadMode = value; }

        }

        public AoWShowMode ShowMode

        {

            get { return _showMode; }

            set { _showMode = value; }

        }

        public AoWBlendMode BlendMode

        {

            get { return _blendMode; }

            set { _blendMode = value; }

        }

        public Int32 BlendValue

        {

            get { return _blendValue; }

            set { _blendValue = value; }

        }

        public AoWClipXHack ClipXHack

        {

            get { return _clipXHack; }

            set { _clipXHack = value; }

        }

        public AoWAutoShift AutoShift

        {

            get { return _autoShift; }

            set { _autoShift = value; }

        }

       

        public List<AoWBitmap> SubImageList

        {

            get { return _subImageList; }

        }



        // state utility

        public bool Is8bpp()

        {

            return _imageType == AoWImageType.Type01_Picture08_0x01

                || _imageType == AoWImageType.Type02_RLESprite08_0x02

                || _imageType == AoWImageType.Type03_Sprite08_0x03;

        }



        public bool IsPlain()

        {

            return _imageType == AoWImageType.Type16_Picture16_0x10

                || _imageType == AoWImageType.Type01_Picture08_0x01;

        }



        // constructors

        public AoWBitmap()

        {

            _name = string.Empty;

        }



        #region ICloneable Members



        public virtual object Clone()

        {

            throw new Exception("The method or operation is not implemented.");

        }



        #endregion

}

Name: Anonymous 2011-09-12 8:01

Amazing post.

Name: Anonymous 2011-09-12 8:04

C# stands for COBOL#

Name: Anonymous 2011-09-12 8:07

>>2
Sorry :-(

Name: Anonymous 2011-09-12 8:20

>>1
The only reason why I was unable to puke due to your post was because I hadn't had breakfast yet.

Name: Anonymous 2011-09-12 8:55

C/C++ version is memory unsafe, non-thread safe, isn't multithreaded for efficiency and contravenes Enterprise Design Patterns. Its practically unmaintainable and will be replaced by saner, encapsulated industry-strength ScreenBufferFactory.

Name: Anonymous 2011-09-12 9:07

>>1
OP, your C# code is retarded, but I assume you wanted it to be like that to spread the propaganda.

Name: Anonymous 2011-09-12 9:27


        public int Top

        {

            get { return top; }

            set { top = value; }

        }

        public int Left

        {

            get { return left; }

            set { left = value; }

        }

        public int Right

        {

            get { return right; }

            set { right = value; }

        }

        public int Bottom

        {

            get { return bottom; }

            set { bottom = value; }

        }

Why don't you use a macro for that?

Name: Anonymous 2011-09-12 9:30

>>1
First memcpy is very generic in what it does (it copies memory). The other code copies some object piece by piece (which can have its advantages when you want to properly deal with references and actually clone an object (you should see what mess that could end up in C++, or even C)). You could do some memory copying using unsafe code in C# (or most other high-level languages). Either way, shallow/deep copying is different from memcpy. To understand why you need it (yes, even in C), you need to work on large projects dealing with fairly complex data structures (watch the C code bloat to hell then).

Not that I'm defending C#, just that these are separate issues which apply to both high-level and low-level languages (and high-level languages can benefit from low-level hacks if you want to, at the same time, implementing high-level features in low-level languages tends to lead to immense bloat if done "properly" or without hacks).

Name: Anonymous 2011-09-12 10:08

>>8
Because he's being silly. public int Top { get; set; }; etc. would be perfectly sufficient.

Name: Anonymous 2011-09-12 11:13

C# has GC --> Shit

Name: Anonymous 2011-09-12 11:57

I don't have much experience with C#, never picked it up because of the platform dependency. Is it really as dildos as people say?

Name: Anonymous 2011-09-12 12:29

>>12

You write on it pretty much like Java. It's actually a Java with a little more things done right, but with the downside of the .NET Platform not being as "free" and "portable".

Mono still sucks ass and features one of the most uncivilized devteams I ever saw.

Name: Anonymous 2011-09-12 12:33

>>11
Kill yourself, Kodak.

Name: Anonymous 2011-09-12 14:17

>>7
your C# code is retarded
It isnt mine code. I got it from http://aow.heavengames.com/ in hope to retrieve RLE algorithm. But due to C# nuances it was harder than I thought.

Name: Anonymous 2011-09-12 14:59

>>14
Who the hell is Kodak?

Name: Anonymous 2011-09-12 15:03

GC is shit.

Name: Anonymous 2011-09-12 15:10

>>16
A horrible, obnoxious tripfag troll.

Name: Anonymous 2011-09-12 15:20

>>18
Hmm, I remember him now... It was quite funny, until he trolled me :/

Also, GC is shit.

Name: Anonymous 2011-09-12 15:25

seebad? get some glasses and seesharp!

Name: Anonymous 2011-09-12 16:31

GC is great.

Name: Anonymous 2011-09-12 19:02

>>21
No, it isn't.

Name: Anonymous 2011-09-12 19:41

>>22
Yes it is.

Name: Anonymous 2011-09-13 0:00

the purpose of attributes is that you DON'T have to write them prematurely.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List