SRL Archive - Help

Bitmaps


Yago

2011-04-22 18:41:11

Is there a way to get a bitmap from a web page and set it as a variable?

Sex

2011-04-22 19:07:39

Yes.

Edit: I can't remember how I did it….
Edit2: Here is something I made like 2 years ago. It worked with SCAR, not sure about Simba. Omg, that isn't the same as what you wanted D:
Maybe, a combination of that and LoadBitmap though? :)

Edit3: So many edits..I see a lot of things wrong with that function now that I am familiar with Linux :p. Like lowercase filename and shit.
Do you want me to write a new one or you think you got it? Basically, getpage the bitmap, save, and LoadBitmap.

Yago

2011-04-23 00:24:14

I see, but that function downloads the actual image… Is ere a way to just use it such as

S := getpage(blah)
Bitmapvar := blah...

Dgby714

2011-04-23 00:46:09

function BitmapFromWeb(Web: string): integer;
var
Data: string;
FileNum: integer;
begin
Data := GetPage(Web);

if (FileExists(IncludePath + 'temp.bmp')) then
FileNum := RewriteFile(IncludePath + 'temp.bmp', True)
else
FileNum := CreateFile(IncludePath + 'temp.bmp');
WriteFileString(FileNum, Data);
CloseFile(FileNum);

Result := LoadBitmap(IncludePath +'temp.bmp');
end;

cycrosism

2011-04-23 02:22:14

Check my sig for my bitmap tutorial, i have quite a few things but nothing on this, sorry. What Dgby714 posted should work fine

Yago

2011-04-23 11:35:45

From: Dgby714
function BitmapFromWeb(Web: string): integer;
var
Data: string;
FileNum: integer;
begin
Data := GetPage(Web);

if (FileExists(IncludePath + 'temp.bmp')) then
FileNum := RewriteFile(IncludePath + 'temp.bmp', True)
else
FileNum := CreateFile(IncludePath + 'temp.bmp');
WriteFileString(FileNum, Data);
CloseFile(FileNum);

Result := LoadBitmap(IncludePath +'temp.bmp');
end;



Thanks a lot Dgby714. :)

Do you think people would mind having an extra bitmap on their computer? Or should I delete it after running a script?

Sex

2011-04-23 15:30:13

No, it is easier on the servers. They should keep it on their computer :).

Yago

2011-04-23 16:45:46

I keep getting an error doing this…:

function BitmapFromWeb(Web: string): integer;
var
Data: string;
FileNum: integer;
begin
Data := GetPage(Web);

if (FileExists(IncludePath + 'CookPaint.bmp')) then
FileNum := RewriteFile(IncludePath + 'CookPaint.bmp', True)
else
FileNum := CreateFile(IncludePath + 'CookPaint.bmp');
WriteFileString(FileNum, Data);
CloseFile(FileNum);

Result := LoadBitmap(IncludePath +'CookPaint.bmp');
end;

var
Chat: Integer;

begin
Chat := BitmapFromWeb('http://img153.imageshack.us/f/lcpaint.png/');
end.

Error:

Exception: Error while reading stream: Wrong image format at line 16

Sex

2011-04-23 16:52:52

Bitmap != png :o

Yago

2011-04-23 17:20:02

I saved it as a bmp on imageshack. The file it creates is empty and also a .bmp

Ill try another uploader see if it changes the extension

Edit: Anyone know of a website that doesn't change the image extensions?

Edit2: Got it to work by using a file hosting site… Thanks guys

Dgby714

2011-04-23 17:53:42

You can leave it as temp.bmp unless you add cache'in or somethin its only used right after its downloaded.

Sex

2011-04-23 17:55:43

From: Dgby714
You can leave it as temp.bmp unless you add cache'in or somethin its only used right after its downloaded.

Hey man, RewriteFile creates it if it doesn't exist.